yeah, if you are not using cross domain calls, dump the callback parameter there, it's totally no needed... and if you are not using cross domain, then you aren't/don't-need-to use or think about "jsonp" at all
as for mime type of normal json: application/json or text/plain also works for fine (in my experiences anyways) On Oct 27, 6:49 am, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: > On Mon, Oct 26, 2009 at 9:58 PM, MorningZ <morni...@gmail.com> wrote: > > > if this is your *exact* code > > > $.getJSON(url + "?callback?", function (json) { > > > then you're missing an equal sign > > > $.getJSON(url + "?callback=?", function (json) { > > Good catch! Fortunately I had the = in my real code. I just forgot to > type it in the email. > > > As for the rest of your issue of "what to do", this post should help: > > >http://groups.google.com/group/jquery-en/browse_thread/thread/fd821bf... > > Okay, I think I understand about using jsonp now. I don't think I need > it in my case though because my call isn't cross-site. So I still have > these questions: > > 1) What should the response type be when using jsonp? > 2) What should the response type be when not using jsonp? Is that just > called plain json? > 3) When not using jsonp, what should the server code return? Still > JavaScript code that calls the callback function with the json content > or just the json content? > > > > > On Oct 26, 8:14 pm, Mark Volkmann <r.mark.volkm...@gmail.com> wrote: > >> I have some code working that invokes an HTTP service that returns JSON. > >> From my JavaScript I call the service with: > > >> $.getJSON(url + "?callback?", function (json) { > >> // do something with json here > > >> }); > > >> My service is implemented as a Java servlet with a doGet method. > >> In that method I: > >> 1) set the content type of the response to "application/x-javascript". > >> 2) get the value of the callback parameter > >> 3) create a Java Map > >> 4) use the org.json library to convert the map to JSON text > >> 5) build a string of JavaScript code that calls the callback function, > >> passing it the JSON > >> 6) write the string of JavaScript to the response > > >> Is this the recommended approach? I was expected that > >> I wouldn't need to pass the callback function name to the servlet and > >> could just return the JSON from the servlet instead of a string of > >> JavaScript code. > > -- > R. Mark Volkmann > Object Computing, Inc.