简体   繁体   English

使用jQuery加载页面

[英]Load a page using jquery

I want to know about the error happened during inserting the html code in the page this is my jquery code : 我想知道在页面中插入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");

the error says : SCRIPT5007: 'undefined' is null or not an object 错误显示:SCRIPT5007:'undefined'为null或不是对象
the stop line is : var count = theForm.elements.length; 停止线是:var count = theForm.elements.length;

debugger is Microsoft internet explorer 9.0 beta 调试器是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');
   }
 });

You should use a callback function for the complete event: 您应该对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