File Location:

  1. index.php is at the root (well, I think this is understandable)
  2. myvxo_VH.js loaded into the index file from the js/myvxo_VH.js
  3. vxod.php also lies at the root.

Now the code itself:

 $(document).ready(function() { $('#FormVsxod').click(function() { var user1 = $('#LogOtprav').val(); var pas1 = $('#PasOtprav').val(); /* Вариант 1 $.ajax({ type: "POST", url: "vxod.php", data: "user="+user1+"&pas="+pas1, success: function(msg){ alert( msg );//данные } }); */ //Вариант 2 $("#lsVH").load( "vxod.php", { user: user1, pas: pas1 }, function() { alert("Получен ответ от сервера.") } ); //не тот не другой не работают. Единтсвенная //разница так это в 1 врианте всё таки вызывается алерт //но пустой, тоесть отсета от сервера нет //а во втором вообще никакой риакции. }); }); 

index.php does not have a single line of php code. Only html and connection scripts. And in vxod.php only one line.

 echo "Рас два три проверка". 

Did so. But not what did not work: /

 $.post("/vxod.php",{'user' : user1, 'pas': pas1},onAjaxSuccess)}; function onAjaxSuccess(data){ alert(data); } 
  • Maybe you should open the developer console and find out what's there? - u_mulder
  • There is nothing there. Errors do not give says all the rules. - user181105
  • The first thing I would check is that the click processing function is called. Banal add console.log ("I'm click function"); At the very beginning of each function can greatly help. - KoVadim
  • Is the code called at all? form #FormVsxod is on the page? s most likely superfluous in V s hod - PashaPash
  • 2
    Is there a dot at the end in echo? echo "Раз два три проверка"; - igumnov

2 answers 2

it is possible for example

 function sendAJAX(user, pas) { $.post("/vxod.php",{'user' : user, 'pas': pas},onAjaxSuccess)} 

onAjaxSuccess is the onAjaxSuccess that the response from the server will go to

    try this:

     $.ajax({ url: "/vxod.php", type: 'POST', data: JSON.stringify({'user' : user1, 'pas': pas1}), headers: { 'Content-Type': 'application/json' }, success: function (data) { //some code } });