所以我有一個目錄名爲paste.php一個PHP文件與域example.com(http://www.example.com/ajax/paste.php) PHP文件看起來像一個服務器:阿賈克斯jQuery的請求到另一個域
<?php
$id=($_GET['create']);
$paste=($_GET['paste']);
$toly=($_GET['toly']);
if($id=='create'){
echo "hello";}
else{
echo "world";
} ?>
在另一臺服務器不同域我有一個簡單的HTML文件(www.example /演示/ index.html的) 我想提出一個AJAX調用PHP文件上面沒有運氣 我的jQuery的樣子:
var url="http://www.example.com/ajax/paste.php";
s="create=create&paste=hello&toly=this";
$.ajax({
type: "GET",
xhrFields: {
withCredentials: true
},
url: url,
data: s,
success: function(msg){
alert(msg);
},error:function (jqXHR){
alert(jqXHR.status.error);
}
});
我是什麼d錯了嗎?
編輯:忘記XHR我只是想找回我已經爲響應 字符串有什麼辦法?
看到http://stackoverflow.com/questions/727183/can-jquery-ajax-call-external-webservice –