how to do an if with php parameters within javascript

-1

I need to do a check before changing html elements, I tried that way but it did not work, it does not go into if under any circumstances.

    <script>
    if("<?php empty($usuario_pesquisado->getArea()->getNome()) ?>")
    {
        $('#area_item').css("opacity", 0.4);
    }
    if("<?php  empty($usuario_pesquisado->getFormacao()) ?>")
    {
        $('#formacao_item').css("opacity", 0.4);
    }
   </script>
    
asked by anonymous 11.10.2018 / 03:43

1 answer

0

Man, I would make a request with AJAX getting the values from the PHP page:

$.get( "ajax/test.html", function( data ) {
  $( ".result" ).html( data );
  alert( "Load was performed." );
});
    
14.10.2018 / 01:19