function?test(){
????var?json1?=?{
????????"name":"John",
????????"type":"Infinite",
????};
????var?result?=?submit();
????document.getElementById('title').innerHTML?=?result;
}
function?submit(data){
????var?xmlhttp;
????window.XMLHttpRequest?xmlhttp=new?XMLHttpRequest:xmlhttp=ActiveXObject('MicrosoftXMLHTTP');
????xmlhttp.onreadystatechange?=?function(){
????????if(xmlhttp.readyState?==?4?&&?xmlhttp.status?==?200){
????????????console.log("Everything?in?Server?side?goes?well!");
????????????//document.getElementById('title').innerHTML?=?xmlhttp.responseText;
????????????return?xmlhttp.responseText;
????????}
????}
????xmlhttp.open('GET','http://johnkreed.ns1.cscces.net/echo.php?data='+data,?true);
????xmlhttp.send();???
}這種方式將json數(shù)據發(fā)送到服務器端不知道可不可以,服務器端的PHP我也不知道怎么驗證。只知道返回過來的數(shù)據在網頁上顯示“undefined".正確的應該怎么做?
javascript怎么通過ajax發(fā)送json到服務器端php接收頁面?
約翰姜
2015-10-14 14:49:33