[jQuery] Submitting form via AJAX
>I have a secondary question on this code. How would this AJAX function be
"called" (in this particular case)? Is it jus on form submit?
This is the code. It is callen in a click event on a button:
-------------
$('#user_rating_form input[@type="button"]').click ( function() {
doSubmit = false;
$('#user_rating_form input[@type="hidden"]').each( function() {
if ( $(this).val() != 0 ) doSubmit = true;
});
if ( doSubmit == true )
{
$("#user_rate .valuations_actions").hide();
$("#user_rate .wait").show();
$('#user_rate input[@type="button"], #user_rate
input[@type="reset"]').set("disabled","true");
$.ajax({
url: "/ajax/ajax_process.phtml",
type: "post",
data: $.param( $("#form").formdata() ),
success: function(xml) {
alert ( $(xml).html() );
},
error: function() {
alert ("KO");
}
});
}
else
{
alert ( "You have to valuate at least one parameter" );
}
return false;
});
------------------
$.param( $("#form").formdata() ) doesn't work, and if i replace it by an
simple array,
success: function(xml) {
alert ( $(xml).html() );
},
Doesnt' work neither, it launch an "undefined" alert. The script that
processes de data is usign correctly "text/xml" headers. In fact, i'm using
this processing script in an old version of the js, that uses the $.post
function.
Thanks,
Albert Garcia
OboLog » Tus pensamientos en red
www.obolog.com
______________________________________________
Mi blog personal en http://obokaman.obolog.com
________________________________
De: discuss-bounces@jquery.com [mailto:discuss-bounces@jquery.com]
En nombre de Andy Matthews
Enviado el: miércoles, 12 de julio de 2006 17:45
Para: jQuery Discussion.
Asunto: Re: [jQuery] Submitting form via AJAX
<!----------------//------
andy matthews
web developer
certified advanced coldfusion programmer
ICGLink, Inc.
andy@icglink.com
615.370.1530 x737
--------------//--------->
-----Original Message-----
From: discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com]On Behalf Of Albert Garcia
Sent: Wednesday, July 12, 2006 10:36 AM
To: 'jQuery Discussion.'
Subject: [jQuery] Submitting form via AJAX
Hi guys,
I'm trying to implement some AJAX in a form, using 1.0a
version of Jquery.
I have a couple of questions:
- In principle, I've read in the docs at
http://proj.jquery.com that the form plugin is included in this version, but
formdata() or serialize() function doesn't work.
$.param( $("#form").formdata())
- Regarding to new way of calling AJAX functions ( $.ajax
instead of $.post & $.get ):
I'm trying to make this call
$.ajax({
url: "/ajax/ajax_process.phtml",
type: "POST",
data: $.param( $("#form").formdata() ),
success: function(xml) {
alert ( $("response", xml).text() );
},
error: function() {
alert ("KO");
}
});
But I cannot access the xml contents. What i'm doing wrong.
Have been any changes in the use of this functions? How would be the correct
way of serialize a form values,
and later read the xml after processing it? Any online
examples using 1.0a online version?
Thanks a lot!
Albert Garcia
OboLog » Tus pensamientos en red
www.obolog.com <http://www.obolog.com/>
______________________________________________
Mi blog personal en http://obokaman.obolog.com
<http://obokaman.obolog.com/>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/