文档下载 文档下载导航
设为首页 | 加入收藏
搜索 请输入内容:  
 导航当前位置: 文档下载 > 所有分类 > 工程科技 > 信息与通信 > jQuery.post
侵权投诉

jQuery.post

jQuery.post( url [, data] [, success(data, textStatus, jqXHR)] [, dataType] )

url A string containing the URL to which the request is sent.
data A map or string that is sent to the server with the request.
success(data, textStatus, jqXHR)A callback function that is executed if the request succeeds.
dataTypeThe type of data expected from the server. Default: Intelligent Guess (xml, json, script, or html).


$.ajax({
type: 'POST',
url: url,
data: data,
success: success,
dataType: dataType
});


$.post('ajax/test.html', function(data) {
$('.result').html(data);
});

Examples:
Example: Request the test.php page, but ignore the return results.
$.post("test.php");
Example: Request the test.php page and send some additional data along (while still ignoring the return results).
$.post("test.php", { name: "John", time: "2pm" } );
Example: pass arrays of data to the server (while still ignoring the return results).
$.post("test.php", { 'choices[]': ["Jon", "Susan"] });
Example: send form data using ajax requests
$.post("test.php", $("#testform").serialize());
Example: Alert out the results from requesting test.php (HTML or XML, depending on what was returned).
$.post("test.php", function(data) {
alert("Data Loaded: " + data);
});
Example: Alert out the results from requesting test.php with an additional payload of data (HTML or XML, depending on what was returned).
$.post("test.php", { name: "John", time: "2pm" },
function(data) {
alert("Data Loaded: " + data);
});
Example: Gets the test.php page content, store it in a XMLHttpResponse object and applies the process() JavaScript function.
$.post("test.php", { name: "John", time: "2pm" },
function(data) {
process(data);
},
"xml"
);
Example: Posts to the test.php page and gets contents which has been returned in json format (<?php echo json_encode(array("name"=>"John","time"=>"2pm")); ?>).
$.post("test.php", { "func": "getNameAndTime" },
function(data){
console.log(data.name); // John
console.log(data.time); // 2pm
}, "json");
Example: Post a form using ajax and put results in a div
<!DOCTYPE html>
<html>
<head>
<script src="doc.guandang.net;
</head>
<body>
<form action="/" id="searchForm">
<input type="text" name="s" placeholder="Search..." />
<input type="submit" value="Search" />
</form>
<!-- the result of the search will be rendered inside this div -->
<div id="result"></div>

<script>
/* attach a submit handler to the form */
$("#searchForm").submit(function(event) {

/* stop form from submitting normally */
event.preventDefault();

/* get some values from elements on the page: */
var $form = $( this ),
term = $form.find( 'input[name="s"]' ).val(),
url = $form.attr( 'action' );

/* Send the data using post and put the results in a div */
$.post( url, { s: term },
function( dat

第1页

TOP相关主题

你可能喜欢

热门文档

相关文档

  • JQUERY.post

    jquery的get,post和ajax... 暂无评价 2页 4下载券 jQuery 56页 1下载券 jQuery 3页 1下载券 JQuery 46页 1下载券 jQuery初步 6页 免费...

  • JQuery ajax

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

  • jQuery Ajax全解析

    jQuery Ajax全解析_IT/计算机_专业资料。jQuery Ajax详细解析,包括Ajax、post、get等jQuery Ajax 全解析 jQuery 确实是一个挺好的轻量级的 JS 框架,能帮助我们...

  • jQuery Ajax 全解析(.ajax .post .get)

    jQuery Ajax 全解析(.ajax .post .get)_IT/计算机_专业资料。jQuery Ajax 全解析(.ajax .post .get)jQuery Ajax 全解析【.ajax .post .get】 1. load(...

  • jQuery方法大全

    a : b; } }); jQuery( expression, [context] ) ---$( expression, ...$.ajaxSetup({ url: "/xmlhttp/", global: false, type: "POST" }); ...

  • jQuery_Ajax全解析

    jQuery 代码 代码: $.getScript("AjaxEvent.js", function(){ alert("AjaxEvent.js 加载完成并执行完成.你再点击上面的 Get 或 Post 按钮看看 有什么不同?...

  • jQuery ajax —— 一些细节以及主函数扩展出来的方法

    // 加上get和post方法 jQuery.each( [ "get", "post" ], function( i, method ) { // jQuery.get或jQuery.post为 jQuery[ method ] = function( url...

  • jQuery $.post $.ajax用法

    jQuery $.post $.ajax用法_计算机软件及应用_IT/计算机_专业资料 暂无评价0人阅读0次下载举报文档 jQuery $.post $.ajax用法_计算机软件及应用_IT/计算机_...

  • 异步操作之使用jQuery Ajax

    (这消息来自服务 器)'}"); jQuery 代码: $.post("Ajax.aspx", { Action: "post", Name: "lulu" }, function (data, textStatus){ // data 可以是 ...

  • jQuery的所有方法

    () jQuery.getScript() .load() jQuery.param() jQuery.post() .serialize() .serializeArray() jQuery 遍历函数 jQuery 遍历函数包括了用于筛选、查找和串联...

站点地图 | 文档上传 | 侵权投诉 | 手机版
本站所有资源均来自互联网,本站只负责收集和整理,均不承担任何法律责任,如有侵权等其它行为请联系我们.
文档下载 Copyright 2013 doc.guandang.net All Rights Reserved.  -  email