[英]Ajax call from dropdown select
我正在尝试向下拉菜单中指定的页面发出Ajax请求。 我已经成功地将我的大部分脚本代码用于将鼠标单击绑定到表行,但是在这种情况下,当我在此处尝试操作时,它将无法正常工作。 我收到ReferenceError:未定义fnsuccess。 当我使用此脚本的大部分来绑定鼠标单击时,没有得到此ReferenceError。
<script type="text/javascript">
function isValid(frm){
$("#courseinfo").hide();
$("#frm").validate();
var four04 = $("#frm :selected").val();
console.log('Testing console');
if (four04 == "404")
{
console.log("404");
var txt = ($(this).text());
$.ajax({url:"404.json", data:{coursename:txt}, type:"GET", dataType:"json",
success:fnsuccess, error:fnerror});
function fnsuccess(serverReply) {
if (serverReply && serverReply.info) {
$("#infohere").text(serverReply.info);
$("#courseinfo").show();
} else
fnerror();
}
function fnerror() {
alert("Error occurred");
$("#courseinfo").hide();
}
}
else
{
console.log("else 404");
}
}
</script>
课程->评分404错误403错误
固定:
<script> function isValid(frm){ $("#otherPageContent").hide(); $("#frm").validate(); var dropDownSelected = $("#frm :selected").val(); if (dropDownSelected == "404") { var txt = ($(this).text()); $.ajax({url:"404_error.json", data:{coursename:txt}, type:"GET", dataType:"json", success:fnsuccess, error: function(xhr, status, error){ $("#infohere").text( "The requested page was: 404_error.json" + ". The error number returned was: " + xhr.status + ". The error message was: " + error); $("#otherPageContent").show(); } }); // end of ajax } // end of if 404 function fnsuccess(serverReply) { if (serverReply && serverReply.info) { $("#infohere").text(serverReply.info); $("#otherPageContent").show(); } } return false; // pause message on screen } </script>
在isValid function
外部定义function fnsuccess(serverReply)
和fnerror
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.