javascript - My code works in xampp but not on the 000webhost.com -
when test on localhost works fine when utilize on website "000webhost.com" console writes "bad!" (as in code). have no thought why working on localhost , why not on 000webhost.com
there ajax:
var xmlhttp = (window.xmlhttprequest)?new xmlhttprequest():new activexobject("microsoft.xmlhttp"); xmlhttp.onreadystatechange=function(){ if(xmlhttp.readystate==4 && xmlhttp.status==200){ var resptext = xmlhttp.responsetext; try{ var json = json.parse(resptext); console.log("good!"); } catch(e){ console.log("bad!"); } } } xmlhttp.open(method,url + "?" + parameters,true); xmlhttp.send();
there php:
//$content html code ex: <span>i'm here</span> $resp = array( 'r' => true, 'response' => $content, ); echo json_encode($resp);
when delete try
makes error unexpected token <
sorry english language , give thanks helping.
have checked json? sounds of error, sounds json invalid.
javascript php json
No comments:
Post a Comment