내 질문에 다음과 같습니다 :Ajax json 및 로그인 양식의 매개 변수
jquery 모바일 응용 프로그램에 대한 로그인을 만들고 있습니다. 표준 html 로그인 양식으로이 작업을 수행하고 있습니다. 제출 버튼을 클릭 한 후 제공된 사용자 이름과 비밀번호가 올바른지 확인하고 있습니다. 나는 Ajax와 json을 사용하여 이것을 점검한다. 이제 문제는 내가 할 경우, 다음, 다음과 같습니다
$(document).ready(function() {
//event handler for submit button
$("#btnSubmit").click(function() {
//collect userName and password entered by users
var userName = $("#username").val();
var password = $("#password").val();
});
});
function authenticate(userName, password1) {
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: "http://notgiven",
dataType: 'json',
async: false,
//json object to sent to the authentication url
//data: '{"username": "' + userName + '", "password" : "' + password + '"}',
data: '{username: userName, password: password1 }',
success: function (data) {
//do any process for successful authentication here
alert('Login status: ' + data.status);
}
})
};
:
다음
function authenticate(userName, password1) {
$.ajax
({
type: "POST",
//the url where you want to sent the userName and password to
url: "http://notgiven",
dataType: 'json',
async: false,
//json object to sent to the authentication url
//data: {"username": "' + userName + '", "password" : "' + password + '"},
data: { username: "user1", password: "test1" },,
success: function (data) {
//do any process for successful authentication here
alert('Login status: ' + data.status);
}
})
};
내가 성공을 얻을
하지만 난 내 필드에서 매개 변수를 얻을이 작업을 수행하려면
그럼 내가 실패 ... 아무도 아는 이유 ???
답변 : *답변 : * 답변 : *답변 : 내가 넣어 가지고 *
: 인증 (사용자 이름, 암호); Thrustmaster는 클릭 기능에 을 말했다. 그렇지 않으면 클릭 할 때 사용자 이름과 비밀번호의 데이터가 범위를 벗어나기 때문에이를 수행해야합니다.
나는 또한 false를 반환했습니다. .click 함수에서 두 번 이상 버튼을 클릭 할 수 있습니다. (여전히 함수 인증 결과를 얻습니다.)
THNX
맞습니다! – bdz