当前位置:编程学习 > C#/ASP.NET >>

求一个.ashx页面的post实例

假设我要在给一个页面www.aaa.com/jjjj.ashx发送post,包含字段有title和body,www.aaa.com/jjjj.ashx?title=ttttttttttttttttttt&body=bbbbbbbbbbbbbbbbb  

 这样发送到底对不对。 --------------------编程问答-------------------- 你写的这个url是Get方式就可以了,因为你只是在url中写参数,没有写出半点POST的东西。

你只是写了一个url地址,没有写更多的代码。

你在实际的代码中是如何标记GET和POST命令(method)的呢?贴出你的代码。 --------------------编程问答-------------------- 你这样 写 的是get请求   你要再 form里加个method=post   在ashx里   context。request。form["控件id"] 去获取 --------------------编程问答--------------------
url=encodeURI("www.aaa.com/jjjj.ashx");
            $.ajax({
                      type:"POST",
                      data: { "title": "ttttt", "body": "bbbbb", "datatype": "json" },
                      async:true,                    
                      url:url,
                      dataType:"json",
                      timeout:30000,
                      success:function(data){
                         var Data=data;
                      }
                   });
--------------------编程问答--------------------
引用 2 楼 jiancixiuxian 的回复:
你这样 写 的是get请求   你要再 form里加个method=post   在ashx里   context。request。form["控件id"] 去获取


如果我还想获取返回值呢? --------------------编程问答--------------------
function requestAjax(aurl, adata, adataType, atype, acache, asussess) {
            $.ajax({
                url: aurl,
                data: adata,
                dataType: adataType,
                type: atype,
                cache: acache,
                success: asussess,
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("error:" + XMLHttpRequest + "," + textStatus + "," + errorThrown);
                }
            });
        }

        function searchUser()
        {
            requestAjax
                (
                    "Handle/SearchAllUser.ashx",
                    null,
                    "json",
                    "post",
                    false,
                    function (result) { createTable(result); }
                );
        }
--------------------编程问答--------------------
引用 3 楼 lxrj2008 的回复:
url=encodeURI("www.aaa.com/jjjj.ashx");
            $.ajax({
                      type:"POST",
                      data: { "title": "ttttt", "body": "bbbbb", "datatype": "json" },
                      async:true,                    
                      url:url,
                      dataType:"json",
                      timeout:30000,
                      success:function(data){
                         var Data=data;
                      }
                   });

--------------------编程问答--------------------
引用 3 楼 lxrj2008 的回复:
url=encodeURI("www.aaa.com/jjjj.ashx");
            $.ajax({
                      type:"POST",
                      data: { "title": "ttttt", "body": "bbbbb", "datatype": "json" },
                      async:true,                    
                      url:url,
                      dataType:"json",
                      timeout:30000,
                      success:function(data){
                         var Data=data;
                      }
                   });


这个完全可以 --------------------编程问答--------------------
引用 7 楼 qiujialongjjj 的回复:
Quote: 引用 3 楼 lxrj2008 的回复:

url=encodeURI("www.aaa.com/jjjj.ashx");
            $.ajax({
                      type:"POST",
                      data: { "title": "ttttt", "body": "bbbbb", "datatype": "json" },
                      async:true,                    
                      url:url,
                      dataType:"json",
                      timeout:30000,
                      success:function(data){
                         var Data=data;
                      }
                   });


这个完全可以

顶 --------------------编程问答--------------------
补充:.NET技术 ,  Web Services
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,