Hello! Following code

<script type="text/javascript"> $(document).ready(function(){ $("#buttonUpload").click(function(){ $.ajax({ url: "uploadContent.php", type: "GET", cache:true, data: {data:$("#textUpload").val()}, success: function(data){ $("#dataUpload").html(data); } }); }); }); </script> 

It gets the data parameter in id #dataUpload from the uploadContent.php file. I have this situation, I need to get several uploadContent.php parameters to different id, but I don’t want to repeat a bunch of requests to BD. You need jQuery.ajax to execute 1 request to uploadContent.php and get all the parameters, then scatter them by id.

I would be grateful if someone could help. If you give an article on the work, I will be doubly grateful

  • It is possible as something like $ ("# dataUpload"). Html (data [name]); or whatever be like that. Store in variables or an array ((( - TomasRedl

1 answer 1

Guys all the problem is solved, it is done through JSON

Everyone who looked thanks!

Here is an example.

php

 $street = ['lenina' => '306','mira' => '123']; echo json_encode($street, JSON_UNESCAPED_UNICODE); 

jQuery getJSON

 $.getJSON("/getHouse.php", {}, function(data){ $.each(data, function(key, value){ $("#target").text(value); }); }); 
  • Found on the Internet)))) - TomasRedl