I have this little piece of jQuery/jqModal code which works fine. However, I am trying to add the ability to navigate away from the page when the ajax call succeeds (returns some data).
$(document).ready(function () {
$('#j开发者_如何学PythonqmWindowContainer').jqm({
modal: true,
ajax: ' –- my url –‘,
onHide: myAddClose,
overlay: 0,
ajaxText: 'Loading'
});
function myAddClose(hash) {
hash.w.fadeOut('300', function () {
hash.o.remove();
window.location.href = '/';
});
}
});
In the myAddClose function, how can I conditionally call the “window.location” code instead of calling it every time the function is executed? I only want to navigate if the ajax call returns any data.
Thanks!
Rick
It would seem looking at the documentation for jqModal that the onLoad
call back would work for you.
$('#jqmWindowContainer').jqm({
modal: true,
ajax: ' –- my url –',
onHide: myAddClose,
onLoad: myFuncCalledWhenAjaxHasLoaded,
overlay: 0,
ajaxText: 'Loading'
});
精彩评论