프로젝트를 진행하면서 문제가 발생했습니다. 내 code.Below에서 문제가 무엇인지 찾아 낼 수 없다. Ajax url이 default.aspx의 ReceivedMessageByIndexNumber 함수를 가져올 수없는 이유를 모른다. 고맙습니다.Ajax를 통한 매개 변수 전달
자바 스크립트 :
ReceivedMessage(1);
function ReceivedMessage(indexNumber)
{
$.ajax({
type: "Post",
url: "Default.aspx/ReceivedMessageByIndexNumber?indexNumber="+indexNumber,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (response) {
var data = response.d;
for (var i = 0; i < data.length; i++) {
alert(data[i]);
}
},
failure: function (msg) {
$('#output').text(msg);
}
});
}
을 Default.aspx :
[WebMethod]
public static bool ReceivedMessageByIndexNumber(int textIndex)
{
string connectionString = @"Data Source=localhost;Initial Catalog=NotificationSystem;Integrated Security=True";
using (SqlConnection connection = new SqlConnection(connectionString))
using (SqlCommand command = connection.CreateCommand())
{
connection.Open();
command.CommandText = @"SELECT TextWord FROM TextProperty WHERE TextIndex = '" + textIndex + "'";
command.ExecuteNonQuery();
return true;
}
}
귀하의 쿼리 문자열 매개 변수는 서버 서버 (textIndex) –
나는 그것을 그러나 다시 같은 문제 @에서 예상 이름으로 코드 (indexNumber)의 다른 이름이 메이저 MANN – user3817516
내 대답이 당신에게 효과가 있었거나 무슨 일이 일어 났습니까? 작동했다면 답으로 표시 할 수 있습니까? 감사. – Carter