簡體   English   中英

使用jQuery加載頁面

[英]Load a page using jquery

我想知道在頁面中插入html代碼期間發生的錯誤,這是我的jquery代碼:

        var html = $.ajax({
            url: good.aspx,//in the local domain
            //complete: hideBlocker,
            async: false
        }).responseText;

        $("#HomeView").hide();
        $("#ContentView").html(html); //in this line it gives me script error
        $("#ContentView").show("fast");

錯誤顯示:SCRIPT5007:'undefined'為null或不是對象
停止線是:var count = theForm.elements.length;

調試器是Microsoft Internet Explorer 9.0 Beta

$.ajax({
   type: "GET",
   url: "good.aspx",
   data: "foo=bar&fooo=baz",
   success: function(msg){
     $('#HomeView').hide();
     $('#ContentView').html(msg);
     $('#ContentView').show('fast');
   }
 });

您應該對complete事件使用回調函數:

$.get(
  'good.aspx',
  function (data) {
    $('#HomeView').hide();
    $('#ContentView').html(data);
    $('#ContentView').show('fast');
  }
);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM