Thursday, 15 January 2015

jquery - Webservice functional in SOAP UI but not app -



jquery - Webservice functional in SOAP UI but not app -

i've created simple restful restful webservice i've deployed on glassfish. i've been able utilize webservice soap ui having problem doing same thing presentation layer (simple html page).

this ajax function i'm using:

$(document).ready(function(){ $("#getallcustomers").click(function(){ alert("button functional"); $.ajax({ type: "get", url: "http://localhost:8080/restfulpractice/webresources/customer", success: function(data){ var jsondata = $.parsejson(data); alert("callback function functional"); $.each(jsondata, function(i, item){ this.after("<br><br>"+item+"<br><br>"); }); } }); }); });

the button functional. nil wrong listener. i've triple checked url. doing wrong? can somehow check if response @ server without calling service methods?

edit: ok answer. after checking response in browser found out need add together "access-control-allow-origin" header. whats best way if method i'm using looks this:

@get @override @produces({"application/json"}) public list<customer> findall() { homecoming super.findall(); }

we can send cross domain request via http request call(like in c#,java) using simple html page , seek create service phone call via ajax. before couldn't create cross domain phone call using ajax phone call can. need set crossdomain property true false default in ajax phone call , except jsonp info instead of json. might impact service homecoming info format. here 1 link can prefer more detailing , example. http://www.pureexample.com/jquery/cross-domain-ajax.html

jquery rest java-ee glassfish

No comments:

Post a Comment