我试图使用click函数通过ajax加载innerHTML页面后触发事件,但似乎无法正常工作。我究竟做错了什么?

这是我的代码:

var url;
var textUrl;
$('.linkQuestion').on('click', 'a', function() {
    url = $(this).attr('href');
    textUrl = 'https://s3.amazonaws.com/RichText-javascript/richTextEditor.js?AWSAccessKeyId=ASIAJRENG2ALKWZTWOLA&Expires=1352449392&Signature=Z5GHSw5NaBsDC1c2MwWQC32rVKo%3D&x-amz-security-token=AQoDYXdzECEakAIaCSO9XKqmKgVa/ik%2BPvC1ZfmZEtAuf1MyMhvuXFkES0Io1tP3Lpcm85usfK%2B0/Df4yQYbvNhyT8wq9r7SajzJd%2Bx/luK5AvD08gJuNsXwWuH4S/8edxqJp42q4cmstHl3/ylAD%2BGgIP8IAQI5h6ZccsY4fbPpZryBt8VNtu/22qB53dTWjCwpNlPme6PyW7VDtRQlFBNNqcLfb2pYY6/fqI7jiMj8JgD341N%2BvwH4oSQbhApzRn0fRgzbJU6g8TxRCHCcdJs6le1VmF9vaZmLsng7xjtsBkC5h4djaWsufut1lpYRjgTQIUAn5ZS/d93/TmtRC5l9yNByyT0rqU/ukSAiQksUWgoyRq0r/Cp/QyDMg/GEBQ%3D%3D';
  $('.answers').load(url, function() {
    $.getScript(textUrl, function(data, textStatus, jqxhr) {
        console.log(data); //data returned from getScript
        console.log(textStatus); //return "success"
        console.log(jqxhr.status); //200
    });
  });
});

最佳答案

不知道我是否了解您需要做什么。 getScript具有成功回调

$('.linkQuestion').on('click', 'a', function() {

var url = $(this).attr('href');
var textUrl = 'https://s3.amazonaws.com/RichText-javascript/richTextEditor.js';

$('.answers').load(url, function() {
    $.getScript(textUrl, function(data, textStatus, jqxhr) {
        console.log(data); //data returned from getScript
        console.log(textStatus); //return "success"
        console.log(jqxhr.status); //200
    });
});


});

10-07 22:03