php - How to catch a response in a "POST" request? -


i have html/jquery webpage , php server. webpage making "post" request server :

var data = '{"deviceuuid":"' + userid + '"}'                  $.ajax({                      type: "post",                      url: "http://192.138.2.113/server_cityinfo/wheresubscribed.php",                      data: data                       }) 

as can see send id , in json format. request arrives @ server , after "cooking" make echo server webpage :

echo json_encode($result); 

sorry if question sound stupid , how "catch" echo webpage jquery?

the php server on separate origin (different ip, domain, subdomain, or protocol) web page. because of this, request being caught same origin policy.

there 3 common ways fix this:

you can use jsonp, mean having use rather post, , server have return data in jsonp format.

you can use cors, php server have implement cors headers , have implement patch jquery (or send request manually) support ie8 , ie9. ie7 not support cors @ all.

the third option use proxy either on webserver, or on third party server implements cors or jsonp. common third party service helps yql, , there's done example here.


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -