I am new to web dev.
I am working on a project (web app, running on jetty port 8081) which is supposed to call the web services from another web app, running on jetty port 8081.
How do I do that?
I am new to web dev. I am working on a project (web app,
Share
When you’re running a server locally on your computer (like jetty), the root url is always
localhost:portnumberso if you have a web service running on port 8081, it can be accessed by connecting to the url
http://localhost:8081as for calling the services. Javascript offers AJAX (asynchronous javascript and xml) as a method to send and receive for example HTTP requests between the browser and the server. I suggest using jQuery’s ajax implementation as it is nicely abstracted. In backbone.js the communication between the application and server is done with models and collections. Remember that backbone assumes you’re running a RESTful web service serving up json.
UPDATE:
Because of the same-origin-policy of web browsers ajax can be normally used only to make calls to the origin of the site making the call (same protocol + domain name + port number). This can be circumvented in a controlled manner with for example JSONP, that instead of JSON returns arbitrary Javascript code. In jQuery’s ajax, you can use JSONP to make requests to ‘foreign’ servers by setting the
dataTypeas'jsonp'.Hope this helps!