在asp.net中调用JQuery中的服务器端方法
在我的应用程序中,我有一个表单,用户首先输入他们的用户名。现在我应该检查该用户名是否可用,我有一个方法“用户名”,该方法返回 true 或 false 作为返回类型。 在这里,我正在使用 jQuery 和 ajax 来实现这个概念。 一旦用户输入此名称,并且当他进入第二个文本框键入此代码时,应该执行此代码并将结果作为弹出窗口[moda popup] 提供给他。如果用户名已在使用中的方法“用户名”返回值为 true,则需要显示消息“用户名已在使用中” 如果返回值是 false“不需要显示”,
现在我的代码看起来像这样,
<head>
<title>Calling an ASP.NET Page Method with jQuery</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "Default.aspx/Username",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: OnSuccess,
error: OnFailure
});
});
function OnSuccess(result)
{
// so here i need to check whethere true or false
// based on that i need to show modal pop up
alert("Success!");
}
function OnFailure (result)
{
alert("The call to the page method failed.");
}
</script>
</head>
任何解决方案都会很棒 谢谢
in my application i have an form where user enter their username first . now i should check whether that username is avilable or not i have wtitten an method "username" which does this whuch return true or false as a return type.
here i am doing using jQuery with ajax to achive this concept.
once the user enter this name and when he goes for the second textbox to type this code should get executed and give him the result as a pop up[moda popup] . if return value is true from method "username" from user name is already in use need to display message "username alredy in use"
if return value is false "no need to display"
right now my code looks like this
<head>
<title>Calling an ASP.NET Page Method with jQuery</title>
<script type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$.ajax({
type: "POST",
url: "Default.aspx/Username",
contentType: "application/json; charset=utf-8",
data: "{}",
dataType: "json",
success: OnSuccess,
error: OnFailure
});
});
function OnSuccess(result)
{
// so here i need to check whethere true or false
// based on that i need to show modal pop up
alert("Success!");
}
function OnFailure (result)
{
alert("The call to the page method failed.");
}
</script>
</head>
any solution on this would be great
thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)