Php+jquery cross-domain submission problem, don't mind it. It's only 20 points.
1: A domain server-side output JSON is as follows
$test = "{name:\" john\ ", message:\" Hello john\ "}";
Echo $test;
2: The B Domain Server program is as follows
function SendEmail () {
var Orderingid = $ ("#orderingId"). Val ();
alert (Orderingid);
$.ajax ({
Type: "Get",
URL: "http://www.testB.com/cronemail/cron_expressmail.php?orderingid=2222",
DataType: "Jsonp",
JSONP: "Callbackfun",
Jsonpcallback: "Jsonpcallback",
Success:function (JSON) {
alert (json.message);
}
})
}
But the page tip error:
User agent: mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; trident/4.0; SV1;. NET CLR 2.0.50727;. NET CLR 3.0.4506.2152;. NET CLR 3.5.30729)
Timestamp: Tue, Oct 10:48:39 UTC
Message: Script Error
Line: 0
Character: 0
Code: 0
uri:http://www.test.com/cronemail/cron_expressmail.php?orderingid=2222&callbackfun=jsonpcallback&_= 1382438914750
Share to:
------Solution--------------------
Ajax can't cross domain, that's the fact that it's indisputable
Your code is only a formal cross-domain and is actually
So the URL must return a valid JS statement
Just a JSON string is not enough.