function postData() { var post = ""; $(":text").each(function() { post += "&" + this.name + "=" + this.value; }); $(":password").each(function() { post += "&" + this.name + "=" + this.value; }); return post; } var ajaxCheck = function(dataStr) { $.ajax( { type: "GET", async: false, url: window.location.href, dataType: "json", data: dataStr, success: function(data) { flag = data.Result; message = data.Message; dbExists = data.Exists; } }); } //调用 urlStr = "type=checked" + postData(); ajaxCheck(urlStr);