I have a javascript part running on a berth server that sends XMLHTTPRequest to scoket on another server (wamp server). The request is sent to the socket, however the XHR response seems to be blocked.
I heard that I can use JSONP to solve this problem. However, since I am new to javascript and I never used the JSONP technique before I would really appreciate any help on using this technique?
function sendPost(url, postdata, callback) {
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null) {
alert ("Browser does not support HTTP Request")
return
}
xmlHttp.onreadystatechange=callback
xmlHttp.open("POST",url,true)
xmlHttp.send(postdata);
}
function sendInitRQ(width, height) {
var post = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><command type=\"init\"><width>" + width + "</width><height>" + height + "</height></command>";
sendPost("http://localhost:80/socket.php", post, initReturned);
}
I know that a php socket receives a message, as when I check the server log, I get 200 receive requests.
I just want to know how can I use the JSONP approach? I have seen examples of the approach, but I still don't know how to do this.