无法在函数内调用ashx [英] Cannot invoke ashx inside the function
本文介绍了无法在函数内调用ashx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有jquery代码来调用ashx文件.页面加载时可以完美地工作.当我从另一个函数调用该函数意味着不起作用.我将两个代码放在这里.
I am having jquery code to invoke ashx file. Its perfectly working while page load. When i call the function from another function means not working.I have place the two codes here.
请检查并帮助我.
<script type="text/javascript">
$(document).ready(function () {
try {
$("#submit").click(function () {
var user = $("#login").val();
var pass = $("#password").val();
CallLoginHandler(user, pass);
}
}catch(ex){
}
</script>
<script type="text/javascript">
function CallLoginHandler(user, pass) {
$.ajax({
type: "POST",
url: "../handler/JQGridHandler.ashx?MainPage=GetUserDetails&Type=2&user=" + user + "&pass=" + pass + "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.length > 0) {
alert(response[0]["FLD_ID"]);
//successCallback(response);
} else {
alert(response[0]["FLD_ID"]);
}
}
});
}
</script>
推荐答案
我认为您缺少正确的jquery语法.尝试以下修改后的代码:-
I think you are missing the proper jquery syntax . Try the following modified code :-
<script type="text/javascript">
$(document).ready(function () {
try {
$("#submit").click(function () {
var user = $("#login").val();
var pass = $("#password").val();
CallLoginHandler(user, pass);
});
} catch (ex) {
}
});
function CallLoginHandler(user, pass) {
$.ajax({
type: "POST",
url: "../handler/JQGridHandler.ashx?MainPage=GetUserDetails&Type=2&user=" + user + "&pass=" + pass + "",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
if (response.length > 0) {
alert(response[0]["FLD_ID"]);
//successCallback(response);
} else {
alert(response[0]["FLD_ID"]);
}
}
});
}
</script>
这篇关于无法在函数内调用ashx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文