2258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a competition
+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
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Sells items exclusively on Envato Market
  • Located in United States
+4 more
DesignerThemes
says

Try changing the:

$(this).attr('action')

To:

$('form#commentform').attr('action')
2229 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+11 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;
});
2258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a competition
+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); 
2229 posts
  • Located in Europe
  • Made it to the Authors' Hall of Fame
  • Had an item featured on Envato Market
  • Participated in a focus group or interview to improve the user experience on Envato Market
+11 more
revaxarts
says
Do you get a valid URL with
alert(_this.attr('action'));
2258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a competition
+13 more
mpc
says

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

Yeap I do get a valid URL ;/

2258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a competition
+13 more
mpc
says

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

2258 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Sells items exclusively on Envato Market
  • Won a competition
+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