Writing a jquery function to check whether password user enters is already in use.
Using a blur event to send via post() value to a coldfusion page that returns ‘ok’ or false.
Using firebug, looks like am sending and receiving the expected data.
I’m guessing that perhaps my problem is in the return function. My first alert for resp gives correct. However, regardless the resp value (whether it is ‘ok’ or ‘notok’, I get the “else” option in the test.
Appreciate any thougts as what I wrong. (This is my first stackoverflow post, so hope I am doing this correctly!) Here is function that is called on the “ready”. As I said, the jquery blur and the post seem to be correctly functioning. (I also used get() with same result.)
function setAjaxCk() {
$('#password').blur(function(){
var myVal = $('#password').val();
if (myVal.length < 1){
return false;
}
$.post("ajxTest.cfm",{myWord: myVal, myType: 'pw'},
function(resp) {
alert(resp);
if(resp == 'ok'){
alert('things are alright');
} else {
alert('a problem here');
}
});
return false;
});
}
What is the dataType of the post ? JSON i assume, can you try adding datatype = JSON in your jQuery.post and then re run your code ?