This is the documentation!
$.ajax({
url: mydomain.com/url,
type: POST,
data: $.param( $(#form).formdata()),
complete: myAjaxDone,
success: myAjaxSuccess,
error: myAjaxError
});
However I can't find an explenation for this line.
data: $.param( $(#form).formdata())
What
What is param and what is formdata
formdata() is an old function that used to exist in the form plugin
long ago. $.param is a core method which converts an object or an
array into a query string.
How can I submit a form then via ajax?
Use the form plugin:
Mike Alsup schrieb:
$.param is a core method which converts an object or an
array into a query string.
I wonder if there is any case where one would use $.ajax without calling
$.param for any data first. If not, it would be nice to simply integrate
that call into $.ajax.
--
Jörn
I wonder if there is any case where one would use $.ajax without calling
$.param for any data first. If not, it would be nice to simply integrate
that call into $.ajax.
That's a good point, Jörn.
___
jQuery mailing list
discuss@jquery.com
Mike Alsup schrieb:
I wonder if there is any case where one would use $.ajax without calling
$.param for any data first. If not, it would be nice to simply integrate
that call into $.ajax.
That's a good point, Jörn.
Of couse it would be an ugly API change. If that stuff is
Of couse it would be an ugly API change. If that stuff is integrated
into $.ajax, we could savely deprecate $.get and $.post.
Perhaps interrogating the type would work?
if (typeof data != 'string')
data = jQuery.param(data)
___
jQuery mailing
Mike Alsup schrieb:
Of couse it would be an ugly API change. If that stuff is integrated
into $.ajax, we could savely deprecate $.get and $.post.
Perhaps interrogating the type would work?
if (typeof data != 'string')
data = jQuery.param(data)
Yeah, that should be pretty safe.
While we are at it: A get request can send it's data only by appending
the query string to the URL, right? Can this be handled by $.ajax, too?
Sure, it could. I think it makes sense to move all that logic into
$.ajax but I would keep $.get and $.post because they are nice
convenience methods.
Mike Alsup schrieb:
While we are at it: A get request can send it's data only by appending
the query string to the URL, right? Can this be handled by $.ajax, too?
Sure, it could. I think it makes sense to move all that logic into
$.ajax but I would keep $.get and $.post because they
So don't see the need for $.get and $.post anymore.
It's not a need, it's a convenience. Just like getJSON and getScript.
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/
Mike Alsup schrieb:
So don't see the need for $.get and $.post anymore.
It's not a need, it's a convenience. Just like getJSON and getScript.
Ok, $.get and $.post both provide an interface with static parameters,
that makes them more convienent then $.ajax.
Good to talk about it
11 matches
Mail list logo