我想用jQuery来修改一些来自AJAX的内容,但由于某种原因它似乎无法访问内容。我对jQuery仍然很陌生,所以我不确定哪里出了问题,并希望这里有人能指出我的方向。AJAX后通过jQuery修改内容
所有的代码位于GitHub上这里https://github.com/Ryan-Myers/WordPress-Survey-Plugin/blob/master/survey-js.php
但相关代码如下(这是一个WordPress插件BTW的一部分):
//Add a new question to the passed survey
function add_question(survey_id) {
var data = {
action: 'survey_add_question_ajax',
security: '<?php echo wp_create_nonce("survey_add_question_nonce"); ?>',
survey: survey_id
};
jQuery.post(ajaxurl, data, function(response) {
jQuery('#survey-admin-page').html(response);
jQuery('#survey-questions-table').slideUp();
jQuery('#survey-add-question').slideDown();
});
//FAILS HERE
jQuery('#survey-add-question').ready(function(){
//Default to hiding the question setup until they select a question type.
jQuery('#questionsetup').hide();
jQuery('#save_question').attr('onclick', 'submit_question('+survey_id+')');
//Testing to see if it will return a usable value, which it doesn't.
alert(jQuery('#save_question').attr('onclick'));
});
}
+1为slideDown的回调,我认为这是需要在这里。 – GregL
经过漫长的夜晚,我感觉很累,而且听起来声音很好。我只是想说你是对的,并在早上核实。非常感谢你 :) – Ryan