473,394 Members | 1,679 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

What does query string look like on the receiving end

Claus Mygind
571 512MB
In my code I am sending a number of records via an ajax post method to the web-server for updating a table. I will parse the query string when it is received on the server side. But I am not sure if I need to make each element in each record a unique name/identifier. Right now I was just trying to figure out what the query string looks like when it arrives at the server.

I kind of see the errors of my ways, but would like some clarification. Instead of separating each element with an &, I could use some other delimiter, so it will be only 1 large string which I would parse. Or as I assemble the string (see code below line 38) I could attach a row # to each element in each row ie: GroupKey1, GroupName1...., GroupKey2, GroupName2.....

Not sure what is the best option or can I just send multiple records with the same identifiers?

Each record consist of just 4 fields

GROUPKEY = GROUPNAME + JDEPTID + PHASECODE
GROUPNAME
JDEPTID
PHASECODE




Expand|Select|Wrap|Line Numbers
  1. /*
  2.     Ajax communication with server section
  3.     for submtting updated templates.
  4. */
  5. var tempHttp;
  6.  
  7. function submitTemplates()
  8. {
  9.     if (window.ActiveXObject) 
  10.     {
  11.         tempHttp = new ActiveXObject("Microsoft.XMLHTTP");
  12.     }else if (window.XMLHttpRequest) {
  13.         tempHttp = new XMLHttpRequest();
  14.     }
  15.  
  16.     var url = "upDateTemplates.exe?timeStamp=" + new Date().getTime();
  17.     var queryString = buildQueryString();
  18.     tempHttp.onreadystatechange = handleStateChange;
  19.     tempHttp.open("POST", url, true);
  20.     tempHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  21.     tempHttp.send(queryString);
  22. }
  23. function buildQueryString()
  24. {
  25.     var cG        = ""
  26.     var cD        = ""
  27.     var cP        = ""
  28.     var cString = ""
  29.     for (i in aTemplates )
  30.     {
  31.         cG = i;
  32.         for (n in aTemplates[i])
  33.         {
  34.             cD = n.substring(1);
  35.             for (p in aTemplates[i][n] )
  36.             {
  37.                 cP = p.substring(1);
  38.                 cString += "GROUPKEY="+cG+cD+cP+"&GROUPNAME="+cG+"&JDEPTID="+cD+"&PHASECODE="+cP+"&"
  39.             }
  40.         }
  41.     }
  42.     cString += "method=POST";
  43.     return cString;
  44. }
  45.  
Nov 13 '08 #1
4 3266
Dormilich
8,658 Expert Mod 8TB
or you could use a serializer. serialize your object/array/variable in javascript and unserialize it in your server script. you got one large string to submit and less work on splitting it up on the server.

regards
Nov 13 '08 #2
Claus Mygind
571 512MB
Very interesting but I do not know what a serializer is. All my data as you can see does come from a javaScript array of objects. So if you could show me some example code to follow that would be great.
Nov 13 '08 #3
acoder
16,027 Expert Mod 8TB
Depends on your server-side language. In PHP, for example, you can use array notation, e.g. GROUPKEY[] and use the same name. In Coldfusion, same name fields would appear as a list. Other languages may have something similar.
Nov 13 '08 #4
Claus Mygind
571 512MB
Thanks for the update, that helps. In the language I am using with the pre-defined modules the info is simply read into an array. So with your help and just a little coding sense I solved my issue.
Nov 13 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Resant | last post by:
I have a query : Exec 'Select * From Receiving Where Code In (' + @pCode + ')' @pCode will contain more than one string parameter, eg : A1, A2, A3 How can i write that parameters, I try use :...
17
by: Paul | last post by:
HI! I get an error with this code. <SCRIPT language="JavaScript"> If (ifp==""){ ifp="default.htm"} //--></SCRIPT> Basicly I want my iframe to have a default page if the user enters in...
140
by: Oliver Brausch | last post by:
Hello, have you ever heard about this MS-visual c compiler bug? look at the small prog: static int x=0; int bit32() { return ++x; }
0
by: karinski | last post by:
Hi All, I have a split f/e - b/e setup on my database with RWOP queries on the front end. The code below gets a PO number(s), and vendor name from a multi choice list box on another form. It...
3
by: Jim | last post by:
I'm trying to develop an Internet application using an Access database, and I'm trying to insert records using an insert query. I keep receiving an error stating that I need to use and updatable...
1
by: news.microsoft.com | last post by:
I want to have one machine encypt a string value(in memory not disk), and then pass that new value to another machine, where it will be decrypted back to its original value. I have no idea on...
4
by: johnny | last post by:
hi all, I hope it is easier for you to answer than for me trying to explain it... In a database I have some tables , each one has some mandatory fields at the beginning and a couple at the...
3
by: Aliriazi | last post by:
All, I have created a simple database, which includes a receiving table and outgoing table in my receiving table I have a multiple entry of the same fields. I am trying to create a query that...
7
by: spk | last post by:
Hello, So I once took a class in Access but have since forgotten if this is possible or not....I have set up a switchboard that runs a macro query to display list of results in datasheet view. The...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.