Hello. In the address bar link site.ru/folder/index.php? id = 1 You need to send an AJAX request to which you need to send the GET value of the id parameter

The request looks like this:

.getJSON('/folder/ajax.php', { id: /*тут значение id*/ } 

How to get the GET value? I would be grateful for the help.

  • Where to get the GET value in which language you are writing the backend part, how is it possible? JAVA PHP NodeJS C # everywhere in different ways What happens .... - Shnur
  • @Shnur sorry, forgot to clarify. php - iKey

1 answer 1

Something like this, if the method parameter does not send a GET, then replace it with type

 $.ajax({ method: 'GET', url: '/folder/ajax.php', data: {id: 1} }).done(function(data){ }); 

php code

 <?php $id = empty($_GET['id']) ? '' : $_GET['id'] 
  • why data: {id: 1} ? The id value will always be different in the URL. and how do I get the value of the GET parameter - id - to substitute into my request? -
  • You asked for an example, I gave you an example, you can substitute a variable that will send different IDs, the answer is given according to the formulated question) Formulate a more correct question to get the answer you need))) - Shnur