您的位置:首页 > Web前端 > JQuery

jQuery $ajax $post $get

2016-06-21 10:23 507 查看
$("#inner").click(function () {

$.ajax({
type: 'post', 

                url: '__URL__/run1',
data:'{}',
dataType: 'json',

                contentType: 'application/json;charset=utf-8',

                beforeSend: function () {

                running = true;

                    timer = setInterval(function () {

                        i += 5;

                        outter.style.webkitTransform = 'rotate(' + i + 'deg)';

                        outter.style.MozTransform = 'rotate(' + i + 'deg)'

                    }, 1);

                },

        success: function (data, textStatus) {
alert(textStatus);

var description = ""; 

for(var i in data){ 
var property=data[i]; 
description+=i+" = "+property+"\n"; 

alert(description); 
alert(JSON.stringify(data));

                },

               error: function(XMLHttpRequest, textStatus, errorThrown) {
alert('XMLHttpRequest.status = '+XMLHttpRequest.status);
alert('XMLHttpRequest.readyState = '+XMLHttpRequest.readyState);
alert('textStatus = '+textStatus);
alert('errorThrown'+errorThrown);

                },
complete: function (XMLHttpRequest, textStatus) {

},

                timeout: 4000

})// $.ajax//;

$.post('__URL__/run1', '', function (data) {
alert("提交成功,谢谢您的参与");
  
alert(JSON.stringify(data));  
}, "json")

})// $("#inner");//

});//$(function ()//

$.post('__URL__/run1', '', function (data) {

alert("提交成功,谢谢您的参与");
  
alert(JSON.stringify(data));  

}, "json") ;

$.get("test.php", function(data){  

alert("Data Loaded: " + data);

});
http://www.w3school.com.cn/jquery/jquery_ref_ajax.asp
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: