取消jQuery发布到ASP.Net WebMethod
我正在开发一个web应用程序,该应用程序通过点网web方法实时查询MS-SQL,如下所示: jQuery取消jQuery发布到ASP.Net WebMethod,jquery,asp.net,sql-server,ajax,webmethod,Jquery,Asp.net,Sql Server,Ajax,Webmethod,我正在开发一个web应用程序,该应用程序通过点网web方法实时查询MS-SQL,如下所示: jQuery var xhr = $.ajax({ type: "POST", url: "page.aspx/SearchMatchingRecords", data: "{ company:'" + company + "', country:'" + country + "', id: <%= Request.QueryString["id"] %>}",
var xhr = $.ajax({
type: "POST",
url: "page.aspx/SearchMatchingRecords",
data: "{ company:'" + company + "', country:'" + country + "', id: <%= Request.QueryString["id"] %>}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
if (data != "") {
for (var post in data) {
var results = data[post];
var output = '<table ... headers... etc';
for (var i = 0; i < results.length; i++)
{
output += "<tr><td>";
output += #DATA#
output += "</td></tr>";
}
output += '</tbody></table>';
$('[id="fsMatchingRecords"]').append(output);
}
};
return false;
}
})
}
$('[id$="BtnVerify"]').click(function () {
xhr.abort();
});
var xhr=$.ajax({
类型:“POST”,
url:“page.aspx/SearchMatchingRecords”,
数据:“{company:'“+company+”,国家:“+country+”,id:}”,
contentType:“应用程序/json;字符集=utf-8”,
数据类型:“json”,
成功:功能(数据){
如果(数据!=“”){
对于(var post in数据){
var结果=数据[发布];
var输出
[WebMethod]
public static List<MatchingRecord> SearchMatchingRecords(string company, string country, int id)
{
SqlConnection objConn = new SqlConnection(ConfigurationManager.ConnectionStrings["DB"].ConnectionString);
objConn.Open();
List<MatchingRecord> mRecords = new List<MatchingRecord>();
SqlCommand objCmd2 = new SqlCommand("Page_Matching_Records", objConn);
objCmd2.CommandType = CommandType.StoredProcedure;
objCmd2.Parameters.AddWithValue("@company_1", HttpUtility.UrlDecode(company));
objCmd2.Parameters.AddWithValue("@country_2", country);
objCmd2.Parameters.AddWithValue("@id_3", id);
SqlDataReader objDr = objCmd2.ExecuteReader();
int i = 0;
if (objDr.HasRows)
{
while (objDr.Read())
{
mRecords.Add(new MatchingRecord(
Convert.ToInt32(objDr["id"]),
objDr["Rest of Data"]
))
);
}
}
objConn.Close();
return mRecords;
}