我需要发布数据,网址只是"v1/wave",它需要五个参数.我尝试过这个,但到目前为止它没有用:
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);
}
})
Run Code Online (Sandbox Code Playgroud)
错误:未捕获的SyntaxError:url行中的意外字符串.
您应该避免在网址中发送参数.你应该使用该data属性.有几个优点,包括编码..或拼写错误:)
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);
}
})
Run Code Online (Sandbox Code Playgroud)