实现同一主域名上传文件
1、在调用接口页面加入:document.domain = "izsgold.com";
2、接口请求返回加入:<script>document.domain = "xxxx.com";</script>+返回的数据
3、dataType: 'json',过滤json数据中的html
uploadHttpData: function( r, type ) { var data = !type; data = type == "xml" || data ? r.responseXML : r.responseText; // If the type is "script", eval it in global context if ( type == "script" ) jQuery.globalEval( data ); // Get the JavaScript object, if JSON is used. if ( type == "json" ){ var result = data.replace(/<[^>]+>/g,""); data = eval( "data = " + result ); } // evaluate scripts within html if ( type == "html" ) jQuery("<div>").html(data).evalScripts(); return data; }
参考:http://www.ueffort.com/jqueryajaxfileupload-js-duo-wen-jian-shang-chuan-chuan-zhi-kua-yu/