Problem with second execution of js function.

Problem with second execution of js function.

Hi,
I need your help because it happens that in a js function return a value from a file php. This php file is executed via ajax and on success I check the value. At the first execution it returns the right value, after the next exections it returns always the same value. I have to refresh the page to have the right execution.

This is part of the function:

$.ajax({
         type: "POST",
         url: "prenotaVerifica.php",
         data: {preMateria: preMateria, preIdClasse: preIdClasse, preClasse: preClasse, dataPre:dataPre },
         
         success: function(msg){
            $("#spazioEsecuzione").html(msg);
    
         -->   if ($("#okVer").val() == 1) <--
            {                           
                  $("#prenotazioneEseguita").dialog({
                    maxHeight: 500,
                    width: 500,
                    show: 'blind',
                    hide: 'blind',
                    buttons: {
                        Chiudi: function() {
                            $( this ).dialog( "close" );           
                          }
                    }   
                  });
             }
           }
     })

Can someone help me, please?

Thanks in advance.

Tegatti