【www.gdgbn.com--jquery】

jquery.post( url, [data], [callback], [type] )

      通过远程 http post 请求载入信息,使用post方式来进行异步请求。

      这是一个简单的 post 请求功能以取代复杂 $.ajax 。请求成功时可调用回调函数。如果需要在出错时执行函数,请使用 $.ajax。

      返回值:xmlhttprequest

      参数:
      url (string) : 发送请求的url地址。
      data (map) : (可选)要发送给服务器的数据,以 key/value 的键值对形式表示。
      callback (function) : (可选) 载入成功时回调函数(只有当response的返回状态是success才是调用该方法)。
       type : (string) : (可选)官方的说明是:type of data to be sent。其实应该为客户端请求的类型(json,xml,等等)

      示例:
      ajax.asp教程x:

 程序代码
response.contenttype = "application/json";
response.write("{result: "" + request["name"] + ",你好!(这消息来自服务器)"}");
jquery

      代码:

 程序代码
$.post("ajax.aspx", { action: "post", name: "lulu" },
        function (data, textstatus){
            // data 可以是 xmldoc, jsonobj, html, text, 等等.
            //this; // 这个ajax请求的选项配置信息,请参考jquery.get()说到的this
            alert(data.result);
        }, "json");

 


jquery特效处理-前台代码
<script language="网页特效" src="jquery-1.4.2.min.js"></script>
<script language="javascript">
$(function(){//
//ajax代码区
});
</script>


www.forasp.cn


前面讲到了用$.ajax(options)来实现jqueryajax,其中的提交方式是在type中设置,本次讲的ajax是直接标明用post方式来提交数据.
(1)语法:$.get(url,data,fun,type);
url表示ajax调用的页面
date为get方式传递的数据,数据格式{data:value,data:value..}可选
fun是回调函数,function(msg),msg是页面返回内容.可选
type返回内容格式,xml, html, script, json, text, _default。可选
实例:
$("#cn").bind("click",function(){
$.post("index4.php教程",{foraspcnurl:$("#forasp").val()},function(msg){alert(msg);} );
});
例子中的调用页面为index4.php代码如下:.
运行:当在text里面输入网站制作学习网,点击后面的按钮,弹出"网站制作学习网"对话框

这种直接的post方法没有beforsend,error等函数,如果需要在出错时执行函数等,请使用 $.ajax。

本文来源:http://www.gdgbn.com/wangyezhizuo/27468/