I am getting jquery error when i am passing # contain
var url = "/CheckVol/SaveItem?status=" + status + "&name=" + name ;
$.post(url, function(data) {
});
here name contain 'my name # pankaj # lohani # india' , which is creating error.
I am getting jquery error when i am passing # contain
var url = "/CheckVol/SaveItem?status=" + status + "&name=" + name ;
$.post(url, function(data) {
});
here name contain 'my name # pankaj # lohani # india' , which is creating error.
If you use spaces, #, or ? and some other character too. In a querystring value then they must be encoded. the # character can be encoded uisng %23. However Nick's comment is right on. Your already doing a post. Why not just include your Querystring in your posted data?
You need to encode the # using %23
something like this
name = name.replace("#", "%23");
var url = "/CheckVol/SaveItem?status=" + status + "&name=" + name ;
You could encode it using encodeURIComponent(), like this:
var url = "/CheckVol/SaveItem?status=" + encodeURIComponent(status) +
"&name=" + encodeURIComponent(name);
$.post(url, function(data) { });
But it would be better to post the actual data, like this:
$.post("/CheckVol/SaveItem", { status: status, name: name }, function(data) { });
This requires the server looking for it here though, but it's a more appropriate solution I think.