Reputation: 1
contentType: "text/html; charset=utf-8",
url:"secret.aspx?plu="+$("#Text1").val()+"&gh="+$("#TextBox1").val()+"&sid="+$("#TextBox2").val(),
processData: false,
dataType: "html",
success: function(data)
is it the above syntax correct to send the data recieved by the code below
string sid=Request.QueryString["sid"];
string id = Request.QueryString["plu"];
int ide =Convert.ToInt32(Request.QueryString["gh"]);
Response.write(sid);
Response.end();
or is there any other way to achieve the same
Upvotes: 0
Views: 44
Reputation: 64526
The only problem with that request is that it will break if you have any special characters in your input values.
A solution to that would be to pass a data object:
type:"GET",
url:"secret.aspx",
data: {
plu : $("#Text1").val(),
gh : $("#TextBox1").val(),
sid : $("#TextBox2").val()
},
dataType: "html",
This encodes special characters to avoid breaking the key/value format. Alternatively you could keep them in the url
but wrap each in encodeURIComponent()
, which would have the same effect.
Upvotes: 1
Reputation: 6400
You need to serialize your form data into the 'data' option of the ajax method. Also, specify the type of request as GET if you want to use the query string.
type: 'GET'
contentType: "text/html; charset=utf-8",
url:'secret.aspx',
processData: false,
dataType: "html",
data: $('#myForm').serialize(),
Upvotes: 0