javascript - Echoing <script> from PHP to jQuery AJAX causes problems with my interval -


Actually, I'm holding content from a PHP file. I check it every 5 seconds if the content is different from the content on the page, then it loads that new content:

  & lt; Script type = "text / javascript" & gt; $ (Document) .ready (function () {$ .ajaxSetup ({cache: false}); var loadUrl = "& lt ;? php echo site_url (" admin / get_uploads ") ;? & gt;" $ (" .org (result # = "" "# Results"). Html (results); $ ("# result") effect ("highlight", {},}}}}}}}}, 2000);}); & Lt; / Script & gt;  

My PHP is as follows:

  function get_uploads () {$ this-> Db- & gt; By order ('upload_date', 'desc'); $ Upload = $ it- & gt; Jeemodel-> Get_uploads (array ('new' = & gt; TRUE)); Encode '& lt; Script & gt; Function delete_upload (id) {$. Ajax ({type: "POST", url: "'.site_url (" admin / delete_upload ").' / '+ ID, success: function (html) {$ (" # "+ id) .hide ();} }}}  '; if ($ upload == faucet):' no new uploads 'do not resonate; Other: Forex ($ $ upload as $ line): echo' & lt; P id = "'. $ Row-> ID. "" & Gt; '$ Line- & gt; File. ' '. Trencher ('admin / file /'. $ Line-> ID. '/ Absolute', 'complete', 'title = "full"'). ' '.' ('#', 'Delete', 'title = "delete file" onclick = "delete_upload (' .row-> id. '); Return' ').' & Lt; / p & gt; 'endforeach; if end;}  

With the script tag there, my #intv DIVs are loaded continuously. For the reason, Javascript is thinking that there is a difference between content when there should not be. When I remove the tag from my PHP, it should work, it only updates when the new upload is done.

Any ideas that are wrong here?

back to Json Change your function for, and javascript in your processing.


Comments