Hi coaxin26. Your explanation is still very unclear! I am confused. But I have some ideas for you...
Firstly, just checking the obvious, does page1.php know about the jQuery library? Have you included a <script> tag within <head> to reference the jQuery library? Something like the following line is required, but with the correct directory, of course...
- <script src="scripts/jquery-1.8.2.js" type="text/javascript"></script>
Are you saying that the line..
-
<?php echo 'text to appear in the jquery loaded page and which should be appeared in the source code of the page'; ?>
Is failing to display text? If so, then the problem is with PHP, not jQuery. Remember, PHP usually runs on the server not the client browser.
When you load page2 do you need to keep the PHP-generated text (the text in the one-line listing above)? What I mean is; should page2 be loaded within div#ID, but keeping the PHP-generated text also? If so, you could create a proxy <div> beneath div#ID and load page2 into that instead. You could achieve that by changing your .load() to be like this instead...
- $('<div>').appendTo('div#ID').load('page2.php');
I am confused because you say that page2.php is loaded and is visible in source view, but not visible to the user. Is my understanding correct? If so, it sounds like a bug... unless the content of page2.php is perhaps being made invisible because of a CSS rule already existing for page1.php?
Have you got some more jQuery code that runs after the code you listed in your original post? Because $.load() is asynchronous, any code that comes after $.load() will execute before page2.php has finished loading. It can often cause problems.
Is page1.php also being loaded using jQuery code? It could be an asynchronous sequencing issue?
I hope this helps us to resolve your problem.
Best wishes,
Alan