我试图上传并通过AJAX提交表单,我发现jQuery.form插件http://jquery.malsup.com/form/,这是我的代码:
$("#submitSlide").click(function(){
var options = {
success: function(data) {
console.log(data);
},
error : function( jqXHR , textStatus , errorThrown ){
console.log( ' broked ' , jqXHR , textStatus , errorThrown );
} ,
dataType: 'html',
type: 'POST',
url: 'http://www.slideshare.net/api/1/upload_slideshow'
};
$('#ssuploadform').ajaxSubmit(options);
return false;
});
但是我收到这样的错误:
>>[jquery.form] Server abort: Error: Permission denied to access property 'document' (Error)
>>[jquery.form] cannot access response document: Error: Permission denied to access property 'document'
>>[jquery.form] aborting upload... aborted
你知道如何解决这个问题吗?
谢谢,我感谢任何帮助!
解决方法:
从$.ajax()起
Due to browser security restrictions, most “Ajax” requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.
你不能制作跨宗教的XHR.有关创意,请参阅How do I send a cross-domain POST request via JavaScript?.