I see now I misunderstood the complete functionality of "JSONP", no
XMLHttpRequest is made at all, and as a result it's not possible to
control HTTP headers. In my case a script like:
<script type="text/javascript" src="http://localhost:9998/search/jonas?
callback=jsonp1263842210822 "></script>
is injected and and loaded by the browser. Is there a way to check
whether this is loaded at all? I guess the browser will not evaluate
it if the server returns an error-code.

As far as I can see an $.ajax( call which uses JSONP functionality
will never call the error function. This would mean that the option to
use would be to implement custom error handling at the service with
messages and HTTP status code 200.

-- Anton

On Jan 18, 8:26 pm, anton <anton.johans...@gmail.com> wrote:
> A type, sorry, everything works fine without javascript warnings or
> errors, can seem to get any function to be called after a request
> which return 400.
>
> Just fixed the server so that it returns correct MIME-type
> "application/javascript" instead of just text for errors, this wasn't
> the problem though...
>
>       $.ajax({
>                url: "http://localhost:9998/search/"; + searchVal + "?
> callback=?",
>                type: "GET",
>                dataType: "json",
>                success: function() {
>                  alert("success");
>                },
>                error: function() {
>                  alert("error");
>                },
>                complete: function() {
>                  alert("complete");
>                }
>              });
>
> Some Firebug info after a call:
> ===========
> GEThttp://localhost:9998/search/jonas?callback=jsonp1263842210822400
> Bad Request localhost:9998
> Response Headers:
> Server  grizzly/1.9.9
> Content-Type    application/javascript
> Transfer-Encoding       chunked
> Date    Mon, 18 Jan 2010 19:17:15 GMT
> Connection      close
>
> Response = jsonp1263842210822({"msg":"[LDAP: error code 4 - Sizelimit
> Exceeded]"})
> ============
>
> I also find it strange that request is made with Accept Header = */*
> instead of "application/json" which is stated as dataType but should
> maybe be discussed in another topic...
>
> have tried using dataType : "jsonp" and skipped the callback info in
> url, this gives the exact same result though.
>
> On Jan 18, 7:09 pm, Nathan Klatt <n8kl...@gmail.com> wrote:
>
> > On Mon, Jan 18, 2010 at 11:05 AM, anton <anton.johans...@gmail.com> wrote:
> > > Can't seem to get any response from an ajax call which response is 400
> > > Bad Request
>
> > >      $.ajax({
> > >               url: url
> > >               type: "GET",
>
> > Hey, is that missing comma after url a typo?
>
> > Nathan

Reply via email to