ajax总结

来源:互联网 发布:盗号软件制作 编辑:程序博客网 时间:2024/06/15 05:30

jquery ajax调用webservice

http://www.cnblogs.com/zhuawang/archive/2011/07/05/2098652.html

ajax默认为异步,需要同步需要设置属性

<span style="background-color: rgb(254, 254, 242);"> $.ajax({url: some.php,async: </span><span style="background-color: rgb(51, 255, 51);">false</span><span style="background-color: rgb(254, 254, 242);">,success : function(){}});</span>

$.ajax({type:"post",data:{"content":message},beforeSend:function(){loading("请稍后,数据提交中...");},error:function(){loading("remove",1);$(obj).text("提交").attr("onclick","tm_saveComment(this)");},url:"/comment/save/"+periodId,success:function(data){if(data=="success"){$(obj).text("提交").attr("onclick","tm_saveComment(this)");loading("添加成功",1);$("#commentEditor").val("");var user = getUserInfo();$("#comment-list").prepend("<div class='item animated rollIn'>"+"<a href='javascript:void(0);' class='avatar-wrapper' >"+"<img src='"+user.img+"' alt='BLACK8' class='avatar rounded'>"+"</a>"+"<div class='item-wrapper'>"+"<p class='helper'>"+"<a href='javascript:void(0);' class='username' target='_blank'>"+user.username+"</a>"+"</p>"+"<div class='comment-ct'>"+"<p class='the-comment'>"+content+"</p>"+"</div>"+"<div class='helper clearfix'>"+"1秒前"+"  来自:"+user.address+"  "+"<a href='javascript:;' class='btn-reply btn-action-reply'>回复</a>  "+"<a class='btn-vote btn-action-vote' href='javascript:;'><span>赞</span></a>"+"</div>"+"</div>"+"</div>");}else if(data=="fail"){alert("保存失败!!!");}else if(data=="logout"){//在这里一个弹出登陆div层window.location.href = "/login";}}});


0 0
原创粉丝点击