如何将对象作为 ajax get 参数传递?
How to pass object as ajax get argument?
我有以下 ajax 电话:
.ajax({
url: 'uploadExternalImage', //Server script to process data
type: 'GET',
success: function () {
},
// Form data
data: ({url: files[0].link}),
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
在浏览器网络控制台中,我看到发生了以下请求:
http://localhost:8081/member/uploadExternalImage?\[object"%"20Object\]&_=1439918533330"
结果出乎意料
预期结果:
http://localhost:8081/member/uploadExternalImage?url=anyValue
如何更正我的代码?
如果要将数据对象转换为查询字符串,请将 processData 设置为 true。
我有以下 ajax 电话:
.ajax({
url: 'uploadExternalImage', //Server script to process data
type: 'GET',
success: function () {
},
// Form data
data: ({url: files[0].link}),
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
在浏览器网络控制台中,我看到发生了以下请求:
http://localhost:8081/member/uploadExternalImage?\[object"%"20Object\]&_=1439918533330"
结果出乎意料
预期结果:
http://localhost:8081/member/uploadExternalImage?url=anyValue
如何更正我的代码?
如果要将数据对象转换为查询字符串,请将 processData 设置为 true。