如果需要ajax挂钩的特定数据,则需要将其与请求一起发送。
<script>
jQuery(document).ready(function($) {
var data = {
\'action\': \'my_action\',
\'user_id\': 1234
};
jQuery.post(ajaxurl, data, function(response) {
alert(\'Got this from the server: \' + response);
});
});
</script>
多次
wp_localize_script 是一种将php数据输出为javascript对象的简便方法,您可以从
window 对象