echofool 1 Report post Posted October 13, 2010 (edited) Hey,I have a js script which is meant to load a php script inside a div, i get no Js errors according to firebug so i don't know why it won't do it.My script is: function createRequestObject() {var ro;if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safariro = xmlhttp=new XMLHttpRequest(); }else {// code for IE6, IE5 ro = xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }return ro;}var http = createRequestObject();function updateShouts(){ $('#Div').load('content.php');}window.onload = updateShouts(); My page source shows: <script type="text/javascript" src="loaddivcontent.js"></script><div id="Div"></div> Any one see any mistake i made? Edited October 13, 2010 by echofool Quote Share this post Link to post Share on other sites
aspnetguy 30 Report post Posted October 13, 2010 (edited) use this instead window.onload = updateShouts; this assigns the function as the handler what you were doing was assigning the result of the function as the handler. Edited October 13, 2010 by aspnetguy Quote Share this post Link to post Share on other sites
echofool 1 Report post Posted October 13, 2010 (edited) EDIT: just seen you edit the post so ignore this reply post :)EDIT2: okay tried that but still the div is not displaying anything Edited October 13, 2010 by echofool Quote Share this post Link to post Share on other sites
thescientist 231 Report post Posted October 13, 2010 what do you mean loading a PHP script into a div? You realize PHP is executed before HTTP, correct? I could see if you were returning something from a PHP script and then setting the responseText to the innerHTML of a div. What does content.php do? Quote Share this post Link to post Share on other sites
echofool 1 Report post Posted October 13, 2010 (edited) The content.php loads a layout also has some mysql and php stuff going on that works out what layout it is going to be displayed.Content.php is not the same .php script as the which contains the div that is calling it.. the <div id="Div"> is on index.php.Hope this explains. Edited October 13, 2010 by echofool Quote Share this post Link to post Share on other sites
thescientist 231 Report post Posted October 13, 2010 what is it returning? can you just show it to us? Quote Share this post Link to post Share on other sites
echofool 1 Report post Posted October 13, 2010 Argh i got it work now ! Not sure why it works now and did not before unless my browser cached the JS or something! Thanks for your time on helping!!Cheers. Quote Share this post Link to post Share on other sites
aspnetguy 30 Report post Posted October 13, 2010 Argh i got it work now ! Not sure why it works now and did not before unless my browser cached the JS or something! Thanks for your time on helping!!Cheers.If the change you made was in the external JS file it was likely cached. Quote Share this post Link to post Share on other sites