后回来后jQuery的不工作 [英] After post back jquery not working
问题描述
我的组合框中,我从阿贾克斯jQuery的填充数据。它工作正常,但是当我点击保存按钮后后回来后出现回岂不的作品。
I have combo box in which I fill data from ajax jquery. It works fine but when I click save button post back occurs after post back it not works.
这是我的Jquery code。
This is my Jquery code.
$(document).ready(function () {
var EmpCombo = $('#Cmb_PEmp');
var textbox = $("#TxBx_BasicSalary");
var BasicSalary = $('#Hid_BasicSalary');
var EmpID = $('#Hid_EmpID');
EmpCombo.on('change', function EmpCmbFuction(e) {
e.preventDefault();
myEvent();
});
function myEvent() {
var EmployeeId = $('#Cmb_PEmp :selected').val();
if (EmployeeId == 0) {
return;
}
$.ajax({
type: "POST",
cache: false,
contentType: "application/json; charset=utf-8",
url: '/WebService/GetBasicSalaryByEmpID.asmx/GetSalaryByEmpId',
data: '{ "EmployeeId": "' + EmployeeId + '" }',
dataType: 'json',
success: function (data) {
var data = $.parseJSON(data.d)
if (data["BasicSalary"] == 0) {
textbox.val("No BasicSalary Define Yet");
return;
}
textbox.val(data["BasicSalary"]);
BasicSalary.val(data["BasicSalary"]);
EmpID.val(EmployeeId);
},
error: function () { alert("error"); }
});
}
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function () {
$(document).ready(function () {
EmpCombo.on('change', function EmpCmbFuction(e) {
e.preventDefault();
myEvent();
});
});
我如何将修复后回来之后这个问题,不给我正确的结果? jQuery的不执行任何功能。
How I will fix this problem after post back it does not give me proper result? Jquery does not perform any function.
推荐答案
当你正在使用jQuery和你正在使用jQuery阿贾克斯处理你的数据,你为什么不把一个单独的占位符(即deosn't使用更新面板) 。然后你的code将difinitly工作
例如像这样定义一个占位符;
As you are using jQuery and you are handling your data using jQuery ajax, why don't you put a separate placeholder (that deosn't use update panel). And then your code will difinitly work e.g define a placeholder like this;
<asp:Content ID="Content3" ContentPlaceHolderID="RemoveUpdatePanelPlaceHolder" runat="Server">
// your content goes here
</asp:Content>
这篇关于后回来后jQuery的不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!