jquery ajax

$.post()用法

$.post(url,parameters,callBackFunction)

url:abc.ashx,   parameters:{name:"lsun",address:"china"},  callBackFunction:成功的回调函数

在abc.ashx里面使用content.request["name"]获取对象

 

$(function(){
    
        $("input[@type=button]").click(function()
        {
            $.ajax({url:"abc.ashx",type:"post",data:{name:"liqi",address:"china shanghai"},dataType:"html",
             timeOut:2000,error:function(){},success:function(data){alert(data);}});
        });
       
        });

三.$.get("h.ashx",{"term":"liqi"},function(data)
                {
                   
                });

string ps=context.Request.QueryString["term"].ToString();

 

处理JSON
//            $.getJSON("b.json",function(data)
//            {
//                $.each(data,function(entryIndex,entry){
//                    var ss="";
//                    ss+=entry["term"];
//                    ss+=entry["part"];
//                    ss+=entry["definition"];
//                    alert(ss);
//                });
//             });

b.json:

[{
"term":"terry",
"part":"n.",
"definition":"a convenient deity invented by the ancients",
"quote":["is public worship,then ,a sin",
"this for devotions paid to bacchus",
"the lictors dare to run us in"],
"author":"jorace"
},
{
"term":"backbite",
"part":"v.t.",
"definition":"to speak of a man as you find him when "
},
{
"term":"beadr",
"part":"n.",
"definition":"the hair is commonly hello kitty"
}
]

--------------------

//              $.each({"name":"liqi","address":"china"},function(index,value){
//                alert(index+value);
//              })

 

处理xml文件

$.get("d.xml",function(data){
//                $(data).find("entry").each(function()
//                {
//                    var $entry=$(this);
//                    var html="";
//                    html+=$entry.attr("term");
//                    html+=$entry.attr("part");
//                    html+=$entry.find("definition").text();
//                    var $quote=$entry.find("quote");
//                    if($quote.length)
//                    {
//                       $quote.find("line").each(function()
//                       {
//                            html+=$(this).text();
//                       });
//                    }
//                    if($quote.attr("author"))
//                    {
//                        html+=$quote.attr("author");
//                    }
//                    alert(html);

 

jquery XML:

var x = $(

        "<xml><products><product id=/"P1/">AA</product>" +
        "<product id=/"P2/">BB</product>" +
        "<product id=/"P3/">CC<part>X</part></product></products></xml>");
    alert(x.find("products product").size());
    alert(x.find("product:eq(1)").attr("id"));
    alert(x.find("product").eq(2).find("part").text());
    alert(x.find("product[@id='P1']").text());

PS: 在jQuery裡,如果要直接將字串轉成XML物件,記得前後方要加上

Server:

Response.ContentType = "text/xml";
        Response.Charset = "UTF-8";
        //Response.Write("<?xml version=/"1.0/" encoding=/"UTF-8/" ?>");
        //Response.Write("<family>");
        //Response.Write("<father>ChenWei</father>");
        //Response.Write("<mather>MeiXia</mather>");
        //Response.Write("</family>");
        Response.End();

client:

$.ajax({
    url: 'w.aspx',
    dataType:"xml",
    error: function(xhr) { },
    success: function(response)
    {
     
      alert($(response).find("father").text());
       
    }
});
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值