search

Home  >  Q&A  >  body text

javascript - What is the difference between $("...").html() and $("...").load()

$.ajax({

    url:url,                                                  $(dlgId).load(url);
    type:'post',                                              $(dlgId).dialog('open');
    dataType:'html',
    error:function(){
        $.boxUtil.alert("请求异常");
    },
    success:function(data){    
            $(dlgId).html(data);
            $(dlgId).dialog('open');
    }

});
data returns a page. Loading $("...").width() in HTML will report an error.
The url is the request address, and the return is also a page. In the load loading page, the $("...").width() method works just fine, I don't know why

PHPzPHPz2797 days ago578

reply all(1)I'll reply

  • ringa_lee

    ringa_lee2017-05-19 10:29:47

    This is written in the document, jQuery.ajax()里你用dataType: "html"返回的是html纯文本,而用.load()The returned html will be directly inserted into the node wrapped with $. Also, you spelled width wrong. . .

    reply
    0
  • Cancelreply