2012-10-31 41 views
1

我不知道爲什麼彈出式窗口不能自動彈出,當我在html中添加js時,js將檢查數據以獲取「錯誤」/「過期」並且將彈出全屏消息,任何人都可以幫忙?jquery自動彈出數據

這裏是彈出JS:

(function ($) { 
    $(function() { 

      $.get("http://www.theonionism.com/webcontrol/check.php?client=www.theonionism.com", function(data){ 
       console.log(data); 
       if(data == "error"){ 
        alert("Web site error, please contact us"); 
        return false; 
       } 

       if(data == "expired"){ 

        $("body").append('<div class="expried-background"></div><div class="expried-nav">Website already expired, please contact us to resolve the matter.</div>'); 

        $("body").css("margin", "0px"); 
        $(".expried-background").css({ 
        "position":"absolute", 
        "top":"0px", 
        "left":"0px",     
        "background-color":"black", 
        "opacity": "0.8", 
        "z-index": "99999", 
        "width": $(document).width(), 
        "height": $(document).height() 
        }); 

        $(".expried-nav").css({ 
         "position":"absolute", 
         "top": "45%", 
         "height":"40px", 
         "width":"100%", 
         "background-color":"#fff", 
         "z-index": "999999", 
         "font-family":"Arial", 
         "font-weight":"bold", 
         "text-align":"center", 
         "color":"red", 
         "padding-top":"20px", 
        }); 
        return false;    
       } 

     }); 

    }); 
})(jQuery); 
+1

刪除'返回false;'然後再試一次 – StaticVariable

+0

的答覆非常感謝,但仍沒有發生...... http://www.theonionism.com/webcontrol/index.php – user1787516

+0

我得到它現在這由於您匹配的字符串。你有「錯誤」和「過期」,但在它產生的頁面上:(「錯誤」); &(「expired」);這就是爲什麼它不匹配,並沒有顯示你想要的彈出窗口。 – Jai

回答

0

你試過了嗎?他道:

if(data == '("error");'){ 

// do your stuff in case of error 

} 

and 

if(data == '("expired");'){ 

// do your stuff in case of expiration 

} 

讓我知道是否能解決問題。 請不要忘記接受它作爲回答

感謝

+0

上回復err非常感謝你JaiPSah ~~ – user1787516

0

嘗試使用這樣的:

嘗試使用外

function($){}() // remove it and try 

$(function(){ 
    // put your stuff here 
}); 
+0

非常感謝回覆,但仍然沒有發生... http ://www.theonionism.com/webcontrol/index.php – user1787516

0

嗨,我在當地嘗試這樣做,它的工作你需要的方式:

$(function() { 

    $.get("http://localhost/jq/1.php?client=www.get.com", function(data){ 
     if(data == "err"){ 
      alert("Data Loaded: " + data); 

      $("body").append('<div class="expried-background"></div><div class="expried-nav">'+data+'Website already expired, please contact us to resolve the matter.</div>'); 

      $("body").css("margin", "0px"); 
      $(".expried-background").css({ 
      "position":"absolute", 
      "top":"0px", 
      "left":"0px",     
      "background-color":"black", 
      "opacity": "0.8", 
      "z-index": "99999", 
      "width": $(document).width(), 
      "height": $(document).height() 
      }); 

      $(".expried-nav").css({ 
       "position":"absolute", 
       "top": "45%", 
       "height":"40px", 
       "width":"100%", 
       "background-color":"#fff", 
       "z-index": "999999", 
       "font-family":"Arial", 
       "font-weight":"bold", 
       "text-align":"center", 
       "color":"red", 
       "padding-top":"20px" 
      }); 
       return false;    
      } 

     }); 

    }); 
+0

我在1.php – Jai