I need to post data and the url is simply "v1/wave" and it takes five params. I tried this, but it doesn't work so far:
function request(minLat, minLon, maxLat, maxLon, maxNrOfResults, callback){
$.ajax({
url: 'v1/wave?minLat='+minLat+'&minLong='+minLon+'&maxLat='+maxLat+'&maxLong='+maxLong'+&maxNrOfResults='+maxNrOfResults,
type: "GET",
success: function (data) {
callback(data);
if(data.msgCode == LOGIN_SUCCESS){
console.log("request success");
} else if(data.msgCode == LOGIN_FAILED){
console.log("request failed");
}
},
error: function(data) {
handleRequestError(data);
}
})
ERROR: Uncaught SyntaxError: Unexpected string in the url line.
You should avoid sending the parameters in the url. You should use the data
property. There are several advantages, including encoding .. or typos :)
function request(minLat, minLon, maxLat, maxLon, maxNrOfResults, callback){
$.ajax({
url: 'v1/wave',
data: { minLat : minLat, minLong : minLong, maxLat : maxLat, maxLong : maxLong, maxNrOfResults : maxNrOfResults },
type: "POST",
success: function (data) {
callback(data);
if(data.msgCode == LOGIN_SUCCESS){
console.log("request success");
} else if(data.msgCode == LOGIN_FAILED){
console.log("request failed");
}
},
error: function(data) {
handleRequestError(data);
}
})
There's a typo here: '&maxLong='+maxLong'+
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With