jQuery中$.ajax()用法

ajax用法基本用法:

$.ajax({
            type: "post",                          //请求方式分为post/get, 默认为 "get"。
            url: path + "/createDir",        //发送请求的地址,默认为当前页地址。
    async:false, //是否为异步请求,默认为true。
data: {
'token': userinfo.token, 'userid': userinfo.userId, 'pId': pID, 'sId': index, 'dirName': str }, //发送到服务器的数据。将自动转换为请求字符串格式。GET 请求中将附加在 URL 后。 success: function (data) { //如果请求成功,则执行以下函数,并返回参数。 var val = data.ret; if (val == 0) { alert("文件夹已存在!"); $(parent).children("span").html(""); $(parent).children("button,input").show(); $(parent).children("input").focus(); } else { $(parent).children("button,input").hide(); $(parent).children("span").html(str); window.location.reload(); } console.log(data); } });

 

posted @ 2017-03-20 14:45  居然已存在  阅读(466)  评论(0编辑  收藏  举报