简体   繁体   中英

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 :

        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
the stop line is : var count = theForm.elements.length;

debugger is 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:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM