从另一个页面返回后,$(document).ready()无效
I am developing an application in asp.net using c#. In my page I have done ajax call to load the page with html. The html code is coming from the database. This ajax call is written in the document.ready() function. When I am first time loading the page its working fine. When I am going to another page, that is also working fine. But when I am trying to coming back from that page then the document.ready() is not working. For that reason the html code is also not getting populated. How can I solve this issue please help me out from here.
我正在使用c#在asp.net中开发一个应用程序。在我的页面中,我已经完成了ajax调用以使用html加载页面。 html代码来自数据库。这个ajax调用是在document.ready()函数中编写的。当我第一次加载页面时,其工作正常。当我要去另一页时,这也很好。但是当我试图从该页面返回时,document.ready()无效。因此,html代码也没有填充。如何解决这个问题请从这里帮助我。
Document.ready() code is as follows:
Document.ready()代码如下:
$(document).ready(function () {
tempName = GetParameterValues("templateName");
//alert(tempName);
if (tempName != "" || tempName != null) {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "DesignCenter_Static.aspx/loadTemplatePackage",
data: "{'template_name':'" + tempName.toString() + "'}",
dataType: "JSON",
success: function (data) {
var temp_data = data.d.toString();
var temp_arr = new Array();
temp_arr = temp_data.split("|");
$("#divTemplateLayout").html(temp_arr[0].toString());
$("#inputForm").html(temp_arr[1].toString());
$("#divButtonSet").html(temp_arr[2].toString());
$("#inputForm").find('[id^="txt"]').each(function () {
var cName, labelControlName, divControlName, resizeClassName, existingClassName, txtName;
txtName = $(this).attr("id");
cName = txtName.slice(3, txtName.length);
divControlName = "lbl" + cName;
$("#" + divControlName + "").resizable({
maxWidth: 300,
minHeight: 16,
minWidth: 50,
containment: "parent",
autoHide: true,
handles: "n, e, s, w, ne, se, sw, nw"
});
$("#" + divControlName + "").draggable({ cursor: 'move', containment: ".setLimit" });
});
},
error: function (result) {
alert("Error");
}
});
}
$("#ddlZoom").val("100%");
currentZoomLevel = $("#ddlZoom").val();
fillInitialDesignStudio();
});
Back Button Code of another page is as follows:
后退按钮另一页的代码如下:
$(function () {
$("#btnBack").click(function () {
var resPage = GetParameterValues("responsePage");
var tempName = GetParameterValues("templateName");
window.location.href = resPage + "?returnPage=BC_Proof.aspx&templateName=" + tempName;
});
});
Master page code for adding jquery library:
用于添加jquery库的主页代码:
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.placeholder.js"></script>
<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/holder.js"></script>
<%--<script src="js/colpick.js" type="text/javascript"></script>--%>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script type="text/javascript" src="js/placeholders.min.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.js"></script>
<script type="text/javascript" src="js/jquery.uploadify.min.js"></script>
<script type="text/javascript" src="js/spectrum.js"></script>
<script type="text/javascript" src="js/scolor.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript" src="js/jquery.Jcrop.js"></script>
<script src="js/ui/jquery.ui.core.js"></script>
<script src="js/ui/jquery.ui.widget.js"></script>
<script src="js/ui/jquery.ui.button.js"></script>
<script src="js/ui/jquery.ui.position.js"></script>
<script src="js/ui/jquery.ui.menu.js"></script>
<script src="js/ui/jquery.ui.autocomplete.js"></script>
<script src="js/ui/jquery.ui.tooltip.js"></script>
Thanks in advance
提前致谢
1 个解决方案
#1
0
issue is templateName
not getting properly , Check Ajax data,
问题是templateName无法正常运行,检查Ajax数据,
data: "{'template_name':'" + tempName.toString() + "'}",
Your BackButton Code:
你的BackButton代码:
var tempName = GetParameterValues("templateName");
use GetParameterValues("template_name");
instead of GetParameterValues("templateName");
使用GetParameterValues(“template_name”);而不是GetParameterValues(“templateName”);
更多相关文章
- 基于Jquery ui 可复用的酒店 web页面选择入住日期插件
- 在ASPX页面中使用webmethod服务AJAX请求。
- JQuery Mobile 手机显示页面偏小
- Webhoster插入了一个javascript,它会阻止我的代码如何删除它?
- jquery的$.alerts.alert怎么实现点击后跳转页面
- 记录前台页面一些jQuery笔记
- 登陆页面有延迟然后自动向下滚动
- 为什么使用observe_field代码不能使用JQuery模型对话框?
- 加载函数加载页面但不能对数据执行任何操作