Jump to content
echofool

my script won't load [SOLVED]

Recommended Posts

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 by echofool

Share this post


Link to post
Share on other sites

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 by aspnetguy

Share this post


Link to post
Share on other sites

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 by echofool

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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 by echofool

Share this post


Link to post
Share on other sites

what is it returning? can you just show it to us?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...