1
私は結果を得ることを望んでいます:2222。しかし、今結果を得ることができません。常に '3333'を出力します。 誰でも私を助けることができますか?ありがとうございます!asp.netでjquery ajaxのCSSを変更してください
<head runat="server">
<title></title>
<script src="/Scripts/jquery-1.4.1.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript">
$(function() {
$("#Button1").click(function() {
checkCard('333');
var arrlist = $("span[class='error']");
if (arrlist.length > 0) {
alert('2222')
}
else {
alert('3333');
}
});
})
function checkCard(card_no) {
$.ajax({
type: "GET",
url: "CheckCard.ashx?card_no=" + card_no,
success: function (data) {
if (data == "true") {
$("#sw").addClass("error");
}
else {
$("#sw").removeClass("error");
}
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<span id="sw"></span>
</div>
</form>
<input id="Button1" type="button" value="button" />
</body>
CheckCard.ashx:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
namespace SwipeCard
{
/// <summary>
/// Summary description for CheckCard
/// </summary>
public class CheckCard : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
context.Response.Write("true");
context.Response.End();
}
public bool IsReusable
{
get
{
return false;
}
}
}
}
私は結果を取得したいwolud:2222私は結果を得ることができない.but now.Output '3333' を常に。 誰でも私を助けることができますか?ありがとうございます!