Problems to obtain value "0" or "1" from a div
-
Hi!! so, I have this Ajax function vinculated to a change Jquery event:
$("#nif").change(function(){
$.ajax({
async:true,
type:"POST",
data:N,
url:"basePath("alta/nuevouser/vernifduplicadoajax")?>",
success:function(datos){
$("#res").html(datos);} }); });
The matter is...that the result is or "1" (double register at DB) or "0" (no repeat), the value always appear in the div, depending of this result, I want to activate another
and show a message an other operations.. to evaluate this value I do the next
if($("#res").length !==0){
var warn=parseInt(document.getElementById("res").innerHTML);
alert(warn);
}but I always receive (using alert();)..isNan ...that is, "is not a Number".. I`d need to evaluate: if(warn==1){ //do this }else{ //do that } Thanks a lot in advance!! :)
-
Hi!! so, I have this Ajax function vinculated to a change Jquery event:
$("#nif").change(function(){
$.ajax({
async:true,
type:"POST",
data:N,
url:"basePath("alta/nuevouser/vernifduplicadoajax")?>",
success:function(datos){
$("#res").html(datos);} }); });
The matter is...that the result is or "1" (double register at DB) or "0" (no repeat), the value always appear in the div, depending of this result, I want to activate another
and show a message an other operations.. to evaluate this value I do the next
if($("#res").length !==0){
var warn=parseInt(document.getElementById("res").innerHTML);
alert(warn);
}but I always receive (using alert();)..isNan ...that is, "is not a Number".. I`d need to evaluate: if(warn==1){ //do this }else{ //do that } Thanks a lot in advance!! :)
All that means is that document.getElementById("res").innerHTML does not contain a number. All you have to do is put a breakpoint there, run the code, and see what the value is and you'll figure out what is going on.
Everyone is born right handed. Only the strongest overcome it. Fight for left-handed rights and hand equality.