0

ajaxコールバック内のドキュメントのready()関数内のコードを再呼び出ししようとしています。これは可能ですか?

$(document).ready(function() {
  // page initialization functions
  alert('hi');
});

// this gets called from a button click on the screen
function reauth() {
  // logic here omitted for brevity
  $.post("/Base/reauth", $("#reauthForm").serialize(), function(data) {
    if (data.result != null) {
      $(document).ready();  // <-- this does not invoke the alert('hi');
    }
  });
}
4

2 に答える 2

3
function sayHi() {
  alert('hi');
}

$(document).ready(function() {
  // page initialization functions
  sayHi();
});


// this gets called from a button click on the screen
function reauth() {
  // logic here omitted for brevity
  $.post("/Base/reauth", $("#reauthForm").serialize(), function(data) {
    if (data.result != null) {
      sayHi();
    }
  });
}
于 2012-05-26T19:36:19.793 に答える
2

readyブロック内に関数を配置することはできません:

function something() {
   alert('hi');
}

$(document).ready(function() {
   something();
});

そして、それをもう一度呼び出しますか?

于 2012-05-26T19:35:13.577 に答える