Menu icon Foundation

Designer

My Posts


My Comments

ShadowDanser commented on Lynda Spangler's post almost 6 years

Please let me know if someone got it to work: forms, abide, and submit without page refresh.

After I submit the form I get a page refresh. I also can not get the data with serialize(). There are no errors.

I doubt if the is_ajax check in abide is working correct. I tried to edit it... setting it to true, this works a little bit but then you can hit the submit button only once. The part of foundation remains problematic.

ShadowDanser commented on Lynda Spangler's post almost 6 years

How to send the data? And prevent a page refresh?

Below the code used in F4.

$('#contact').on('valid', function (e) {
  e.preventDefault();

alert('This part works fine')

  $.ajax({
    type: 'POST',
    dataType: 'json',
    data: $(this).serialize(),
    beforeSend: function(x) {
      if (x && x.overrideMimeType) {
        x.overrideMimeType("application/json;charset=UTF-8");
      }
      $('#abS').hide();$('#abA').hide();
    },
    url: '/code/?a=contact',
    success: function(data) {
      if (data.success == true) {
        $('#abS').fadeIn(500);
      }
      else {
        $('#abA').fadeIn(500);
      }
    }
  });
});

I don't get an error. I tried to add $(this).serialize() inside a alert box without success... it remains empty.

How do I serialize and send the data with jQuery Ajax? And prevent a page refresh?

Thanks!

Posts Followed

No Content

Following

    No Content

Followers

My Posts


My Comments

You commented on Lynda Spangler's post almost 6 years

Please let me know if someone got it to work: forms, abide, and submit without page refresh.

After I submit the form I get a page refresh. I also can not get the data with serialize(). There are no errors.

I doubt if the is_ajax check in abide is working correct. I tried to edit it... setting it to true, this works a little bit but then you can hit the submit button only once. The part of foundation remains problematic.

You commented on Lynda Spangler's post almost 6 years

How to send the data? And prevent a page refresh?

Below the code used in F4.

$('#contact').on('valid', function (e) {
  e.preventDefault();

alert('This part works fine')

  $.ajax({
    type: 'POST',
    dataType: 'json',
    data: $(this).serialize(),
    beforeSend: function(x) {
      if (x && x.overrideMimeType) {
        x.overrideMimeType("application/json;charset=UTF-8");
      }
      $('#abS').hide();$('#abA').hide();
    },
    url: '/code/?a=contact',
    success: function(data) {
      if (data.success == true) {
        $('#abS').fadeIn(500);
      }
      else {
        $('#abA').fadeIn(500);
      }
    }
  });
});

I don't get an error. I tried to add $(this).serialize() inside a alert box without success... it remains empty.

How do I serialize and send the data with jQuery Ajax? And prevent a page refresh?

Thanks!

Posts Followed

No Content

Following

  • No Content

Followers