echofool Posted October 13, 2010 Share Posted October 13, 2010 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? Link to comment Share on other sites More sharing options...
aspnetguy Posted October 13, 2010 Share Posted October 13, 2010 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. Link to comment Share on other sites More sharing options...
echofool Posted October 13, 2010 Author Share Posted October 13, 2010 EDIT: just seen you edit the post so ignore this reply post :)EDIT2: okay tried that but still the div is not displaying anything Link to comment Share on other sites More sharing options...
thescientist Posted October 13, 2010 Share 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? Link to comment Share on other sites More sharing options...
echofool Posted October 13, 2010 Author Share Posted October 13, 2010 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. Link to comment Share on other sites More sharing options...
thescientist Posted October 13, 2010 Share Posted October 13, 2010 what is it returning? can you just show it to us? Link to comment Share on other sites More sharing options...
echofool Posted October 13, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
aspnetguy Posted October 13, 2010 Share 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.