Like this:

var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone; 

add this:

  function emailCheckout(form){ var me=simpleCart;counter=1; form.appendChild(me.createHiddenElement("currency",me.currency)); for(var current in me.items){ var item=me.items[current]; form.appendChild(me.createHiddenElement("name_"+counter,item.name)); form.appendChild(me.createHiddenElement("quantity_"+counter,item.qty)); form.appendChild(me.createHiddenElement("price_"+counter,item.price)); var descriptionString=""; for(var field in item){if(typeof(item[field])!="function"&&field!="id"&&field!="qty"&&field!="price"){ descriptionString=descriptionString+", "+field+": "+item[field]}}descriptionString=descriptionString.substring(1); form.appendChild(me.createHiddenElement("item_description_"+counter,descriptionString)); counter++} } 

to make it work:

  $.ajax({ type: "POST", url: "checkout.php", data: dataString, 

And at the end, the forms were cleaned.

Update

Thank you, I use it, but upon completion the window pops up "sent", and if you do not reload the page, it again climbs when the form is displayed (there are no fields to fill in).

  success: function() { $('#bag').html("<div id='message'></div>"); $('#message').html("<h2>Contact Form Submitted!</h2>") .append("<p>We will be in touch soon.</p>") .hide() .fadeIn(1500, function() { $('#message').append("<img id='checkmark' src='images/check.png' 

    1 answer 1

    You need to use another ajax request parameter - success, where you specify your cleaning function. success is a function that is executed as a result of successful completion of the ajax request.

    • Thanks, I use it, but when I finish it, pops up the window "sent", and if I don’t reload the page, it’s again when the form is displayed (there are no fields to fill in) success: function () {$ ('# bag'). html ("<div id = 'message'> </ div> "); $ ('# message'). html ("<h2> Contact Form Submitted! </ h2>"). append ("We will be in touch soon. </ p>") .hide () .fadeIn (1500, function () {$ ('# message'). Append ("<img id = 'checkmark' src = 'images / check.png' - zaza41rus