Can anyone please help me to translate this function in prototype to the equivalent in jQuery
function updateNewsletter(){
if ($('newsletter_dump')){
$('newsletter_dump').remove();
}
newsletterParam = $('newsletter_form').serialize(true);
newsletterParam.template_output = 'box/plugin_newsletter';
new Ajax.Updater('newsletter_form_holder', 'index.php', {
parameters: newsletterParam,
evalScripts: true
});
}
Thanks is advance.
I tried this code but not working. I keep getting an object error
function updateNewsletter(){
if ($('#newsletter_dump')){
$('#newsletter_dump').remove();
}
newsletterParam = $('#newsletter_form').serialize(true);
newsletterParam.template_output = 'box/plugin_newsletter';
$.ajax({
type: 'GET',
url: 'index.php',
data: {"newsletterParam" : "newsletter_form_holder"},
dataType: 'script',
success: function(data){
alert(data);
},
error: function(e){
alert(e);
}
});
}
The problem may come from newsletterParam.template_output = 'box/plugin_newsletter';
Any idea on how to add another form element to the serialised one in jQuery?
Thanks
Unlike Prototype's serialize function, jQuery's serialize function returns a string only. Your error is due to the fact that you are using
newsletterParam
as an object rather than a string. So to fix the problem just append thetemplate_output
parameter as a string:Also, the data setting in your ajax call should be