简体   繁体   English

使用$ .ajax进行jquery加载

[英]jquery load using $.ajax

 <script language="javascript" type="text/javascript">
        $(function () {
            /* HTML Menu Example Code */
            $('#GlobalNav')
                .load('http://navservice.intranet.hpr/api/gethtml', function(){               
                  initmenu();
              });                     
         });
    </script>

How do I convert this to sth like this? 我如何将其转换为某物? except the data type is plain html coming from the webservice? 除了数据类型是来自Web服务的纯HTML?

          $.ajax({
                url: "Common.asmx/InsertClient",
                type: "POST",
                dataType: "json",
                data: "{BizName:'" + BizName + "'}",
                contentType: "application/json; charset=utf-8",
                success: function(msg) {
                    $('#status').html('Id: '+msg['d']['Id']);

                }
            });

$.ajax : $.ajax

$.ajax({
    url: 'http://navservice.intranet.hpr/api/gethtml',
    type: 'GET',
    success: function (html) {
        $("#GlobalNav").html(html);
    }
});

... Or $.get : ...或$.get

$.get('http://navservice.intranet.hpr/api/gethtml', function (html) {
    $("#GlobalNav").html(html);
});

Keep in mind that .load callback function accepts the HTML retrieved from the server, so you may be able to keep using that depending on what you're trying to accomplish. 请记住, .load回调函数接受从服务器检索的HTML,因此您可以根据要完成的工作继续使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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