English 中文(简体)
jQuery 重新调用$( 文件) 。 已经( )?
原标题:jQuery re-call $(document).ready()?
  • 时间:2012-05-26 19:31:11
  •  标签:
  • jquery
  • ajax

我试图在ajax回调中重新激活文档中的代码, 功能已准备就绪 。 这是可能的吗?

$(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 );
    }
  });
}
最佳回答

您不能将函数放入 ready 块中吗 :

function something() {
   alert( hi );
}

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

然后再叫一次吗?

问题回答
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();
    }
  });
}




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签