evaluate div value assigned in php

-2

My problem is as follows. When trying to evaluate the value of a div assigned by PHP with ajax , I can not evaluate the string EMPTY "" as true. Here is a simple example of my problem. messageAjax belongs to a div tag.

<script type="text/javascript">
function comprobar(nick){  
  var url = '/reg/ControlCampos.php';  
  var myAjax = new Ajax.Updater( 'mensajeAjax', url, { method: 'get', onComplete: function(){
    if (

***document.getElementById("mensajeAjax").innerHTML==""*** //NOT WORKING

)
       //ACTION
  }});
} </scrip>'

PHP Code of ControlCampos.php

<?php echo ""; ?>'
    
asked by Mauro Garcia 19.12.2018 в 23:40
source

1 answer

0

Solved. The response of the php file has blank spaces, so it is not possible to directly evaluate the sentence

document.getElementById("mensajeAjax").innerHTML=="" ,

the solution was

document.getElementById("mensajeAjax").innerHTML.trim()==""

that removes spaces in whites.

    
answered by 20.12.2018 в 13:03