View Full Version : Resolved Refreshing Div With JQuery
Jazz914
05-15-2010, 10:21 PM
Hmm.. Is it possbile to refresh a div without having to create an external php file?
It seems silly creating a file just to hold 3 lines of code D:
Jazz914
05-16-2010, 05:18 PM
Bumpy
------
I'm assuming this isn't possible then? ¬_¬
Gjslick
05-17-2010, 03:46 AM
It all depends on what your php file returns. If you don't want to make a new file, then you'd have to add your content into an existing file. That would probably involve having a php if statement that wraps around the page to determine what data to return based on if the request is an ajax request, or a normal request for the file from the browser (which would probably involve sending a URL parameter to the file when it's an ajax request). Ex:
<!-- index.php -->
<?php
if( isset( $_GET[ 'isAjaxRequest' ] ) ) {
// display content for that div
} else {
// display content for the page normally
}
?>
That would lead to some pretty ugly code in your pages...
It really is not silly to create a file that has 3 lines of code just to retrieve the content for your div. In fact, you should separate functionality like that into separate pages. If you were to put the code that gets data for that div somewhere into an existing page, it may not be immediately apparent as to where that code is when you come back to this 6 months down the road.
-Greg
Jazz914
05-17-2010, 10:16 AM
Well, that does seem a bit messy and generally I wouldn't want any unneeded extra things in the URL, I guess i'll just go with the external divs... But I would know where to find the code later in time as the page and the divs content is relative to the page its on :P
Anyway, thanks for the reply ^_^
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.