There is a file layout.php . In it, between the tags <head> jquery.js correctly connected (working link in the source code). When you connect an ajax request to layout.php , nothing is displayed on the page. I connect this way:

 <div id="content"></div> <script> function show(){ $.ajax({ url: '/templates/tribune2/layouts/default/parser_mn.php', cache: false, success: function(html){ $("#content").html(html); } }); } $(document).ready(function(){ show(); setInterval('show()',600000); }); </script> 

I tried to prescribe the url in different ways, zero sense. If the specified code is inserted into the html document, then everything works correctly. Can you please tell me what am I doing wrong?

  • What happens in the browser console? - borodatych
  • In the TypeError console: $ (...). Ready is not a function - andry
  • It seems that you connect jQuery after you connect this script. In any case, this error suggests that the browser does not know the $ variable - Alexander Gribennikov
  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

3 answers 3

1. Check if jQuery is connected at all.
To do this, look at the generated page code:
Ctrl + Shift + U (Win / Lin),
Alt + Cmd + U (Mac)
And see if there is a line with jQuery in the code, and if they are higher than the executable code.

2.If jQuery connects, you need to know if you have another library, which overrides $ .
It is enough to do this:

 <div id="content"></div> <script> /* Закоментируйте временно ваш код */ if( typeof jQuery != 'undefined' ){ alert(jQuery.fn.jquery); } </script> 

If jQuery is connected in an alert there will be a version of the library, which will also mean that $ overrides another library.
If there is no alert, it means that jQuery is not connected at all.

  • Yes, an alert appeared with the library version 1.11.3 - andry
  • If I understand correctly, did the alert output a version of another jQuery library? And if this is true, then I just need to connect to it, disabling the last one? - andry
  • alert($.n.jquery); - give the result? If not, then the console also has the same mistake. This will mean that someone overrides $ . Disable scripts one by one and determine who. - borodatych
  • After turning on the alert line ($. N.jquery); In the code, the kosol produces: TypeError: $ .n is undefined - andry
  • Look for who redefines $ . - borodatych

Try changing the second function to:

 $(document).ready(function(){ setInterval(show, 600000); }); 

And write what after this in the console

  • Replaced function with function. To no purpose And the same mistake - andry
  • Do not mislead people!! setInterval and setTimeout work through a time interval. Your option offers to wait 10 minutes first. Variant TS implies to perform immediately and every 10 minutes. - borodatych
  • Clear. I thought the vehicle was wrong - gndmxsrv

If success does not work, add the query to $ .ajax

 error:function(){ console.log('Ошибка'); } 

And if there is an error, then the error is either in the file (pkhp) or in access to it

  • And where to insert the code? I do not boomubum ... - andry
  • <div id = "content"> </ div> <script> function show () {$ .ajax ({url: '/templates/tribune2/layouts/default/parser_mn.php', cache: false, success: function ( html) {$ ("# content"). html (html);}, error: function () {console.log ('Error');}}); } $ (document) .ready (function () {show (); setInterval ('show ()', 600000);}); </ script> - user206303
  • It was necessary to add this in response. - borodatych