javascript - Receiving multiple variables from a XMLHttpRequest -


i found out how send multiple variables on using this:

xmlhttp = new xmlhttprequest(); xmlhttp.open("get","http://127.0.0.1:3000?var1=" + name + "&var2=test", true); xmlhttp.send(); xmlhttp.onreadystatechange=function(){     if (xmlhttp.readystate==4 && xmlhttp.status==200){      } } 

the problem is, node.js var queryobject = url.parse(req.url,false).query; turns queryobject = 'var1=robert&var2=test'. expecting var1='robert'; var2='test'; there way command?

the way can think of doing doing this:

xmlhttp.open("get","http://127.0.0.1:3000? + name + "&test", true);  , node.js   var queryobject = url.parse(req.url,false).query; var kk = queryobject.split("&"); 

but way doesn't seem work either reason. there simple command i'm missing?

do first way had it:

xmlhttp.open("get","http://127.0.0.1:3000?var1=test1&var2=test2", true); 

and use querystring.parse pull out variables want able read.

var res = querystring.parse(req.url) 

res

{    var1: 'test1',   var2: 'test2' } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -