There is a function in the body of the document:

$(function() { $('.tab-selector').on('click', function() { $(this).addClass('selected'); var tab = $(this).data('tab'), forma = $('#fast_'+tab); $('#'+tab).show().siblings('div').hide(); go_fast_order(forma); } }) 

By clicking, the go_fast_order(forma) function is go_fast_order(forma) , into which I try to transfer an object. The function is in js plugin, here it is:

 function go_fast_order(el){ var forma = $(el).serialize(), data = 'q=checkout_fast.php&', data = data + forma + "&action=yes"; $.ajax({ url : "ajax.php", dataType : "html", data : data, type : "GET", success : function(msg) { } });} 

A click occurs on the <li data-tab="one" class="tab-selector"> element. But serialize() does not work. Tried, so to declare the form var forma = el.serialize() , without result. If you directly specify the desired form id, for example #fast_one , it works without problems. Please tell me what my mistake is.

  • "if we directly indicate the desired id" - where exactly do we specify? when called inside go_fast_order , or inside forma = $(el).serialize() ? - AlexandrX
  • well, in short, console.log (forma) just before the call, and console.log (el) inside the function immediately with the first line ... we look, we compare, we will see later - AlexandrX
  • "Semyon Semyonych!" Thank you for your reply. And I also checked using console.log (). My carelessness, changed the attributes of the data and look forward to happiness. Thanks anyway, they made you doubt and check again .. But do not tell me how to close the topic? - nictboom

1 answer 1

$(el).serialize() - here you just need el.serialize() , because jQuery object already passed to function