私は緊密に結合されたjavascriptを持っています。そこにはif-elseチェックと複数のajax呼び出しがあります。 ajax呼び出しはネストされた型です。私の問題は、深く入れ子にされたAjax呼び出し可能関数であり、そこから正常に出て行きたいということです。ネストされたAjaxから出る方法
コードのスニペットはです。
function showSubscriptionLightBox() {
$.get("/ajax/get_subscription_lightbox_content.php?feed_id=" + feedid, function(data) {
//Work on the data we receive... and check whether user is logged in.
if(userLoggedIn) {
//Make one more ajax call
$.get("/ajax/is_user_subscribed.php?feed_id=" + feedid, function(data) {
//Work on data again.... and check if user is subscribed.
if(userSubscribed) {
//Then there is popup which comes up, a part of same page and it has a button name "task".
document.getElementById('task').onclick = function() {
if(document.getElementById('email_mode').checked) {
$.ajax({
url : "ajax/is_user_email_verified.php?user_id="+userID,
success : function(data) {
if(!data)
return;
var response;
response = eval("response = " + data);
if(!response)
return;
if(response['email_status'] == 0) {
//Exit from here
}}}
...... コードの他の部分..
応答[ 'email_status'] == 0
を教えてくださいときに私は、JavaScriptから正常に終了したいです、 これを行う方法??
私はreturn文を試しましたが、スクリプトの外ではなく囲み関数に私がかかりました。
おかげで、
アミット