It is necessary to output data to the page through ajax (HTML). The data is generated in a loop in a PHP file. That's what I do.

Javascript

$(".nameClass").load( // Скрипт начинает работу сразу после загрузки страницы "dannie.php", { param: "znach" }, function () {}); 

Php

 $param = $_POST['param']; require_once 'connect.php'; // Соединяюсь с БД $zap = mysql_query('SELECT name FROM table ORDER BY '.$param); while ($mass = mysql_fetch_array($zap)){ echo "<br/> "; echo "<div>".$mass['name']."</div>"; } 

Errors do not give any js or php. If output without ajax, everything works fine. And it is necessary through ajax.

  • Naturally jQuery library is connected. - mccrush

2 answers 2

And if so:

 $(".nameClass").load("dannie.php", { 'znach': 'value' } ); 
  • better this way: $ (". nameClass"). load ("dannie.php", {znach: 'value'}); - Artyomich
  • Did not help. - mccrush
  • ajax should jerk dannie.php, I don’t know why he doesn’t draw a DIV at you
  • Thanks for answers. But everything turned out to be much simpler. My not attentiveness. Elementally indicated the wrong class name for the diva where the content should be loaded. - mccrush

Try this:

 $(document).ready(function(){ $(".nameClass").load( // Скрипт начинает работу сразу после загрузки страницы "dannie.php", { param: "znach" }, function(){} ); }); 
  • Smile) Yes, that was done. But obviously this is not the reason, since the rest of the script works. - mccrush
  • 3
    Provide more code, most likely it is not necessary to search for an error here - Artyomich