Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Restful Web service using jQuery ajax
    text
    copied!<p>I've made a RESTful web service at localhost in Java. When I type the following url in my navigator address bar :</p> <pre><code>http://localhost:8080/GeonotesApp2-war/webresources/route/1 </code></pre> <p>It will give me :</p> <pre><code>{"rid":"1","routeComment":"hhhahahahah","routeDateCreate":"2012-04-03T00:00:00+02:00","routeDistance":"13400.0","routeName":"route1","routeUserId":"1"} </code></pre> <p>Now I want to use an Ajax call to get this JSON information with this script :</p> <pre><code>&lt;html &gt; &lt;head&gt; &lt;meta charset="utf-8"&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"&gt;&lt;/script&gt; &lt;script&gt; $(function(){ $.ajax({ type: "GET", url: "http://localhost:8080/GeonotesApp2-war/webresources/route/1", dataType: 'json', headers: { Accept: "application/json", "Access-Control-Allow-Origin": "*" }, success: function(resp) { alert("success"); }, error: function(e) { alert("error: "+e); } }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; Hello Test Service! &lt;/body&gt; </code></pre> <p></p> <p>However I'm always getting the error message : </p> <pre><code>error: [object Object] </code></pre> <p>I found this post and followed exactly what it does, but doesn't work. Can anyone tell me why? Thanks</p> <p><a href="https://stackoverflow.com/questions/9481073/calling-rest-webservice-using-jquery-ajax-call-web-service-is-returning-json-s">Calling Rest webservice using JQuery Ajax call , web service is returning JSON string</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload