我想用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