【发布时间】:2014-06-30 22:01:59
【问题描述】:
我有一些代码。我想在我的代码中添加 jquery 和 ajaxin。我试过但我没有这样做。
这是我的 jQuery 代码
$(document).ready(function () {
$('#btnGOlustur_Click').click(function () {
var Pro_id = $('#drop_p').val(); //drop_p is combobox' name.
var Ity_id = $('#drop_i').val();
var Sta_id = $('#drop_s').val();
document.write("basliyorrrr");
$.ajax({
type: 'POST',
contentType: "application/json; charset=utf-8",
url: 'GorevEkle.aspx/btnGOlustur_Click',
data: "{'project_id':'" + Pro_id + "','status_id':'" + Sta_id + "','itype_id':'" + Ity_id + "'}",
async: false,
success: function (response) {
$('#drop_p').val(''); $('#drop_i').val(''); $('#drop_s').val('');
alert("Record saved successfully in database");
document.write("dataabase e kaydedildi");
},
error: function () {
alert("some problem in saving data");
}
});
});
});
我保存的cs文件
[WebMethod]
[ScriptMethod]
protected void btnGOlustur_Click(object sender, EventArgs e)
{
try
{
MySqlConnection con = new MySqlConnection(Globals.CONNECTION_STRING);
con.Open();
String UserId = Session["user_id"].ToString();
int Pro_id = Convert.ToInt32(drop_p.SelectedValue);
int Sta_id = Convert.ToInt32(drop_s.SelectedValue);
int Ity_id = Convert.ToInt32(drop_i.SelectedValue);
MySqlCommand cmd = new MySqlCommand("INSERT INTO issue (user_id, project_id, status_id, itype_id) values ('" + UserId + "','" + Pro_id + "','" + Sta_id + "','" + Ity_id + "')", con);
cmd.ExecuteNonQuery();
con.Close();
}
catch (Exception err)
{
lbl_hata.Text = "Error reading list of names. ";
lbl_hata.Text += err.Message;
}
Response.Redirect("Profil.aspx");
}
这是我的错误:
在 mscorlib.dll 中发生了“System.Threading.ThreadAbortException”类型的第一次机会异常
mscorlib.dll 中出现“System.Threading.ThreadAbortException”类型的异常,但未在用户代码中处理
【问题讨论】: