I faced with an issue, while I sending Ajax request with data :
myData={Id: "1", userId : "531"};
$.ajax({
type: "GET",
url: 'url_example?',
data: myData,
success: function (data) {
},
error: function () {
}
I receiving next request : https://10.10.10.11/url_example?&Id=1&userId=531
How I can avoid first symbol(&)(after url_example?) from current request ? Thanks.
On the receiving end it doesn't matter if you have an extra & in the query string.
This: url?&a=1&b=2 is the same as This: url?a=1&b=2
Depending on the server-side language you use, you can trim off the "&" on the Request_URI string. But again it's superficial treatment.
Try removing the "?" from the URL parameter. It is implicit from the type: "GET" parameter.
$.ajax({
type: "GET",
url: "url_example",
and so on.
Once you remove the question mark in the url url: 'url_example?' to url: 'url_example', the first & won't be there in the url. More over the server code doesn't work differently with the first &
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.