$.ajaxFileUpload({
url:"http://192.168.0.222:8080/Erp_V0.1/admin/upload/uploader.php", //处理图片的脚本路径
type: 'post', //提交的方式
data: upload_arr,//自定义参数
secureuri :false, //是否启用安全提交
fileElementId :id, //file控件ID
dataType : "jsonp",//数据类型为jsonp
jsonp: "jsonpCallback",//服务端用于接收callback调用的function名的参数
success : function (data){ //提交成功后自动执行的处理函数
alert(1111);
alert(data);
},
error:function(data,status,e){
alert(2222);
alert(e);
alert(JSON.stringify(data));
alert(status);
}
})
jsonp cross-domain only supports get mode. Even if your front-end is set to post mode, it will be automatically converted to get mode.
The implementation method of jsonp is actually the same as the script request address, except that the jsonp of ajax encapsulates it. As you can imagine, jsonp does not support the POST method. Therefore, if your server-side code uses the post method, it will not be able to request.
Of course, if you force yourself to use the post method for cross-domain communication, there is nothing you can do.
Client side changes:
``
Added: crossDomain: true
Modification: dataType: "json"
``
Server side added:
Although it can be done, it has disadvantages and the request time is relatively long. You can weigh the pros and cons yourself.
Finally, attach a related question post on Stackoverflow:
http://stackoverflow.com/ques...
I remember using Get for Jsonp across domains. .But if you insist on posting, there is http://www.jb51.net/article/6..., I haven’t tried it.
First, let’s clear up cross-domain and jsonp related knowledge
jsonp is made with script tags
If the post is to be cross-domain, you need to add Access-Control-Allow-Origin to the backend