How to properly send $ .get from js to php and back There is a code

var test = 'asd'; $.get("ajax.php", {test:test}, function(data){ $('#content').html(data); } ); 

php

 $test = $_POST['test']; echo $test; 

The answer does not come

    1 answer 1

    Everything is very simple. You send a GET request, and in a PHP script you expect to receive a POST.

    Replace $_POST['test'] with $_GET['test'] and everything should work.

    • @nicolaa, if my answer solved your problem, mark it as a solution to your question - tick the left. - neluzhin
    • With pleasure, in 7 minutes) You can accept the answer in 7 minutes - nicolaa