2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Hi, guys I am using the same contact form module in all of my themes, while developing my latest theme I run into a problem:

$.post($(this).attr('action'), formInput, function(data) {                                $('form#commentform').before('<p><?php echo esc_attr($thanks); ?></p>');
});

This bit of code returns a URL not found (404 error) I am not really sure why because the URL is ok and is pointing to the right page. Any ideas?

19 posts
  • Has referred 500+ members
  • Has sold $250,000+ on Envato Market
  • Has collected 1+ items on Envato Market
  • Located in United States
+4 more
DesignerThemes says

Try changing the:

$(this).attr('action')

To:

$('form#commentform').attr('action')
2028 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Provided great feedback to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+9 more
revaxarts says
First
$('#commentform')
is faster than
$('form#commentform')
:) To submit a form with ajax I often do:
$('#commentform').on('submit', function(){
   var _this = $(this);
    $.post(_this.attr('action'), _this.serialize(), function(data){
          _this.before('<p><?php echo esc_attr($thanks); ?></p>');
    });

  return false //prevent native submit;
});
2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Didn’t help, the same problem occurs, any other ideas?

P.S Instead of using _this I use $this :)

 var $this = $(this); 
2028 posts
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Provided great feedback to improve the user experience on Envato Market
  • Interviewed on an Envato blog
+9 more
revaxarts says
Do you get a valid URL with
alert(_this.attr('action'));
2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Do you get a valid URL with
alert(_this.attr('action'));

Yeap I do get a valid URL ;/

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

I am still having this issue, any help would be appreciated …

2195 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+13 more
mpc says

Hi, I found this on the stackexchange.com and it helped:

I could be wrong, but I vaguely remember that: name, email get hijacked by WordPress to do post comments, if you renamed the form elements to be contact-name and contact-email, do you get the same issue?

I had a name conflict :)

by
by
by
by
by
by