View Full Version : Parsing a Querystring in ASP using serverside javascript. Please Help!

05-27-2005, 04:56 AM
Hey guys I am new and in need of help. I have an ASP application written in serverside javascript that uses WinHTTP 5.1 to post to a page and then recieve a response (a query string that looks like the following):


This info is used to create variables and perform further tasks. I have a function that is supposed to handle parsing the string then placing the returned info into variables. The code I am trying to use is below. The problem is that the returned variables that I am creating contain no data!!! Now it is based on some client side code, but it should still work on the server with the changes I have made, can anybody help or make suggestions.



// Read the values from the Response and create a variable
preobjHttpResponse = preobjHttp.responseText;

// function to parse the string begins
function gettheQueryString() {
var theargs = new Object();
// Get Query String
var thequery = preobjHttpResponse;
// Split thequery at the comma
var thepairs = thequery.split("&");

var thecounter = 0;

// Begin loop through the querystring
for(var i = 0; i < thepairs.length; i++) {

// Look for "name=value"
var thepos = thepairs[i].indexOf('=');

// if not found, skip to next
if (thepos == -1) continue;

// Extract the name
var theargname = thepairs[i].substring(0,thepos);

// Extract the value
var value = thepairs[i].substring(thepos+1);

// Store as a property
if (!theargs[theargname]) {
theargs[theargname] = unescape(value);
else {
theargs[theargname] += ("&" + theargname + "=" + unescape(value));

return theargs; // Return the Object

var oQS = gettheQueryString();

// Now, we can access the items:
theRequestResponse = oQS.item1;
theApprovalResponse = oQS.item2;
theavsAddressResponse = oQS.item3;
theavsZipResponse = oQS.item4;
thecvvResponse = oQS.item5;
theProcessVerbiage = oQS.item6;

05-27-2005, 05:13 AM
You should have not started another thread and just PM the mod to move the original thread (http://www.codingforums.com/showthread.php?p=313817) here.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum