I want to ask, can I access the remote server using pure client side scripting language like Javascript, Jquery, ajax
I want to do but there is CORS problem, We can solve it with server side scripting language but how javascript can help us to do this
-
@programmer_1 cross origin resource sharinguser1229968– user12299682012-02-27 11:00:25 +00:00Commented Feb 27, 2012 at 11:00
Add a comment
|
1 Answer
To access a remote server you can either use JSONP to receive data or have the remote server enable CORS, which may not be possibly as you may not have access to it, but if you do this will show you how to enable CORS.
Most web apis support a JSONP request, however. You can use it by passing an additional parameter to the (script-)request and implement a callback function of the same name.
<script src="remote.server.com/api?jsonp=myCallback"></script>
<script>
function myCallback( data ) {
// do some stuff
}
</script>
7 Comments
Sirko
Either check the API description or try the usual parameters
jsonp= or callback= if they return a proper result.Sirko
Is the API even open for public access via http?
|