zoukankan      html  css  js  c++  java
  • JQuery Ajax 请求小结

    包括:$.load();  $.get(); $.post(); $.getJSON();$.getScript();

    $.load("test.htm");表示加载test页面所有元素,即整个页面;

    $.load("test.htm  .para");表示加载test页面中class为para元素的模块;

    $.load("test.htm",{name:"1"},function(){});传参形式;

    demo:

       $(document).ready(function () {
            $("#load").load("load.htm .load_div");
          $("#load").css("background-color", "red");
           
        });

    $.get()与$.post()区别在于后者安全性高,且传输的字符量大;

    通用形式为$.get("test.htm",{},function(){});

     demo:

    $("#btnGet").click(function () {
            $.get("JqueryReceive.aspx", { name: $("#txtContext").val() }, function (data, textStatus) { $("#lblText").html(data); });
        });

    注:只有在textStatus为success情况下才会执行回调函数;

    $.getJSon()获取json数据

     $('#btnDis').click(function () {
            $.get("JqueryJson.aspx", "", function (data) {
                $.each(data, function (i) {
                    var provice = data[i].pro;
                    var html = '<p>' + provice + '</p>';
                    $('#div_3').append(html);
                });
            }, "json");
        });

    $.getScript()

    demo: 

    $("#btnClick").click(function () {
            $.getScript('http://dev.jquery.com/view/trunk/plugins/color/jquery.color.js', function () {
                $("#div_1").animate({ backgroundColor: 'pink' }, 1000).animate({ backgroundColor: 'blue' }, 2000); ;
            });
        });

  • 相关阅读:
    linux mint安装成功
    js 兼容性
    程序员的肚子有多大,水平就有多高
    财富通直连接口for rails3
    ubuntu live cd版本是没有recuse broken system功能
    生活百科
    省市县导入mysql代码,通过csv
    省市县导入mysql代码,通过csv
    休眠、挂起、待机三者之间的区别 收藏
    支付宝接口for rails3
  • 原文地址:https://www.cnblogs.com/FeiyueHang/p/1865106.html
Copyright © 2011-2022 走看看