我正在使用asp.net webforms中的一个项目。模态弹出窗口中有一个表单我想发布该表单。但是在按钮点击中,即使我没有获得文本框和下拉列表的值。所以我决定使用Ajax调用但是遇到了这个问题。
<script type ="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=btnSave]").bind("click", function () {
debugger;
var dd = {};
dd.AttendedBy = $("[id*=AttendByTb]").val();
dd.HandeledBy = $("[id*=HandleByTb]").val();
dd.ClosedBy = $("[id*=CloseByTb]").val();
dd.ActionTaken = $("[id*=ActionDdl] option:selected").val();
dd.SolutionGiven = $("[id*=SolutionDdl] option:selected").val();
var ticket = JSON.stringify(dd);
$.ajax({
url: '/AddTicket.aspx/UpdateTicket',
data: ticket,
dataType: 'application/json',
type: 'POST',
contentType: 'application/json; charset=utf-8',
success: function (response) {
alert("User has been added successfully.");
window.location.reload();
}
});
return false;
});
});
[WebMethod]
[ScriptMethod]
public static void UpdateTicket(Ticket ticket)
{
HelpDeskManager pp = new HelpDeskManager();
pp.UpdateTicket(ticket);
}