0
我想實現與WordPress不過我現在面臨這樣做的任何幫助,將不勝感激阿賈克斯形式與WordPress
HTML
<form class="form-inline" action="wp-admin/admin-ajax.php" id="footer-subs">
<input type="text" name="name" required placeholder="Your Name">
<input type="email" name="email" required placeholder="Email Address" />
<button type="submit" class="red-btn med-btn">Submit</button>
</form>
JQuery的
問題,一個簡單的Ajax形式jQuery('#footer-subs').submit(ajaxSubmit);
function ajaxSubmit(){
var data = jQuery(this).serialize();
//console.log(newSubsForm);
jQuery.post(jQuery("#footer-subs").attr("action"),data, function(info) {
jQuery('h3.subscbribe-box-text').fadeOut(500,function(){
jQuery('h3.subscribe-box-submit').html(info).fadeIn();
});
});
return false;
}
Functions.php
wp_localize_script('ajax-gravityFooterSubs', 'the_ajax_gravityFooterSubs', array('ajaxurl_gravityFooterSubs' => admin_url('admin-ajax.php')));
function gravityFooterSubs(){
var_dump("LOL")
die();
}
add_action('wp_ajax_gravityFooterSubs', 'gravityFooterSubs');
add_action('wp_ajax_nopriv_gravityFooterSubs', 'gravityFooterSubs');
編輯::我得到一個成功的消息淡入爲「0」