Saturday, March 28, 2009

[jQuery] Re: jquery form plugin problem

> I'm trying to use the form plugin from malsup.org to submit a form
> with ajax, but it does not seem to work with options.
>
> This works:
>
>                             $("#loginform").ajaxSubmit(function(obj,
> statusText) {
>                                     alert(obj);
>                             });
>
> This does not work (nothing happens):
>
>                             $("#loginform").ajaxSubmit({
>                                 dataType: "json",
>                                 success: function(obj, statusText) {
>                                     alert(obj);
>                                 }
>                             });
>


Well there must be more to the story than what you're telling us. The
code you've shown above looks fine. Perhaps there is a problem with
the json response.

> Oh, and by the way. Is there any way to get access to the request in
> the 'success' function - to obtain status codes, content-type header
> etc.?


No, not in the success function. But you can use the 'complete'
function to get access to the xhr.

complete: function(xhr, status) {
...
}

No comments: