I am using this Ajax code. But I dont know how i will retrieve my value of value1 on my server-side asp using Javascript.
On my serverside I want to have something
you can make the asp page write the result as JSON format read in directly via XMLHttpRequest Object and later processing:
example of JSON
var myJSONObject = {"bindings": [
{"ircEvent": "PRIVMSG", "method": "newURI", "regex": "^http://.*"},
{"ircEvent": "PRIVMSG", "method": "deleteURI", "regex": "^delete.*"},
{"ircEvent": "PRIVMSG", "method": "randomURI", "regex": "^random.*"}
]
};
then you can use native parsers in web browsers or eval() (NOT RECOMENDED, SERIOUSLY!!!) to parse the data written in your asp page and use it in your javascript client code.
More information about JSON basic info
JSON in browsers:
Here is a very good ajax tutorial. There is everything explained. https://developer.mozilla.org/en/AJAX/Getting_Started
You forget a double quote:
xmlHttp.open("post","CmsAjax.asp",true)
To get the data:
/* this puts the value into an alert */
alert(xmlHttp.responseText);
Whatever the server-side script outputs will be picked up by the AJAX request. So if the AJAX requests something, the server-side does the legwork and fetches the result from the database and then outputs it.
There are loads and loads of tutorials on how to do exactly this. Just ensure that you secure your script properly so that it's not open to abuse.
URL encode _data
and nbquestions
variables. Request.QueryString("param1")
will decode them for you.
JavaScript URLEncode:
escape(_data);
Also you can use Server.URLEncode() methods from VB script.
You need to encode the data on the server and then decode them in the client. You can use JSON-RPC for this.
Here are few links:
Official Website
Wikipedia Article about JSON-RPC
Implementations of JSON-RPC Service in different languages
But you don't need to use JSON-RPC if you have only one value you can encode as JSON in ASP and then decode it in JavaScript
var array = JSON.parse(xmlHttp.responseText);
When your Ajax-Request succeeds you will have the querystring-variables in the QueryString-Collection of the Request-Object.
Could work like this on the server side:
<% var newdata = Request.QueryString("value1"); %>