Hi, i'm trying to make a jsonp servlet but it gives me an error on the response. I'm missing something? maybe on the java servlet? Servelet: HttpServletResponse response; HttpServletRequest request; response.setContentType("application/x-javascript; charset=utf-8"); PrintWriter out = response.getWriter(); out.print(request.getParameter("callback") + "({\"value\":\"test \"})"); out.flush(); out.close(); Jquery: $.getJSON("http://www.myothersite.com/? moreinfo=value&format=jsonp&callback=?", function(data){ alert("success"); }); I make the call for the example on tha API and it worked: $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne? tags=cat&tagmode=any&format=json&jsoncallback=?", function(data){ alert("success"); }); Also, the response of Java Servelet is working but I don't know if it's valid. Respone of my Server: HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: application/x-javascript;charset=utf-8 Transfer-Encoding: chunked Date: Wed, 15 Jul 2009 17:01:39 GMT 15c jsonp1247677616733({"value":"test"}) 0 Response for the flickr server: HTTP/1.1 200 OK Date: Wed, 15 Jul 2009 17:09:37 GMT P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV" Expires: Mon, 26 Jul 1997 05:00:00 GMT Last-Modified: Wed, 15 Jul 2009 17:04:41 GMT Cache-Control: no-store, no-cache, must-revalidate Cache-Control: post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 3898 Connection: close Content-Type: application/x-javascript; charset=utf-8
Hi, i'm trying to make a jsonp servlet but it gives me an error on the response. I'm missing something? maybe on the java servlet? Servelet: HttpServletResponse response; HttpServletRequest request; response.setContentType("application/x-javascript; charset=utf-8"); PrintWriter out = response.getWriter(); out.print(request.getParameter("callback") + "({\"value\":\"test \"})"); out.flush(); out.close(); Jquery: $.getJSON("http://www.myothersite.com/? moreinfo=value&format=jsonp&callback=?", function(data){ alert("success"); }); I make the call for the example on tha API and it worked: $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne? tags=cat&tagmode=any&format=json&jsoncallback=?", function(data){ alert("success"); }); Also, the response of Java Servelet is working but I don't know if it's valid. Respone of my Server: HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Content-Type: application/x-javascript;charset=utf-8 Transfer-Encoding: chunked Date: Wed, 15 Jul 2009 17:01:39 GMT 15c jsonp1247677616733({"lvalue":"value"}) 0 Response for the flickr server: HTTP/1.1 200 OK Date: Wed, 15 Jul 2009 17:09:37 GMT P3P: policyref="http://p3p.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE GOV" Expires: Mon, 26 Jul 1997 05:00:00 GMT Last-Modified: Wed, 15 Jul 2009 17:04:41 GMT Cache-Control: no-store, no-cache, must-revalidate Cache-Control: post-check=0, pre-check=0 Pragma: no-cache Vary: Accept-Encoding Content-Encoding: gzip Content-Length: 3898 Connection: close Content-Type: application/x-javascript; charset=utf-8 � Thanks! any commet it's well received.