- Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
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?
Try changing the:
$(this).attr('action')
To:
$('form#commentform').attr('action')
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
$('#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;
});
- Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
Didn’t help, the same problem occurs, any other ideas?
P.S Instead of using _this I use $this 
var $this = $(this);
- Microlancer Beta Tester
- Author had a Free File of the Month
- Has been a member for 3-4 years
- Item was Featured
- Author was Featured
- Austria
- Exclusive Author
- Referred between 200 and 499 users
alert(_this.attr('action'));
- Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
revaxarts said
Do you get a valid URL withalert(_this.attr('action'));
Yeap I do get a valid URL ;/
- Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
I am still having this issue, any help would be appreciated …
- Sold between 250 000 and 1 000 000 dollars
- Exclusive Author
- Community Moderator
- Author was Featured
- Bought between 10 and 49 items
- Referred between 200 and 499 users
- Has been a member for 4-5 years
- Won a Competition
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 
