曉得雜解決跨域 吧 我用的是ajax請求的var tep="網(wǎng)絡(luò)原因出錯(cuò)";tep=$.ajax({url:"http://openapi.baidu.com/public/2.0/bmt/translate?client_id=2ALMz6WqUEcsBg4BS91Eppq3&q="+str+"&from=auto&to=auto",type:"post", dataType:"html",data: "name="+vg,error: function(){ // alert("Http status: "+xhr.status+" "+xhr,statusText+"\najaxOptions:"+ajaxOptions+"\nthrownError:"+thrownError+"\n"+xhr.responseText );alert("請?jiān)O(shè)置:Internet選項(xiàng)-安全-自定義級別-其它-跨域訪問數(shù)據(jù)源設(shè)置為“啟用”狀態(tài)");},success:function(msg){var msg = eval("("+msg+")");//接受翻譯后返回來的結(jié)果obj.innerHTML=msg.trans_result[0].dst;//翻譯后的結(jié)果}});
- 1 回答
- 0 關(guān)注
- 738 瀏覽
添加回答
舉報(bào)
0/150
提交
取消