Reload content without page refresh

Status
Not open for further replies.

AmN

Active Member
342
2009
41
185
Hello,
I need help with reloading some part of page, actualy i want to make reload some content (post) on my wordpress blog without reloading page.. simple users can click on refresh button and get new post ...

Im make random.php file and im include in my page this file, so there is 6 random posts...
<?php include 'random.php';?>
So now i need reload this part on click without reloading all page, im try found solution on the google but cant find any good tutorial or example..

This works
Code:
<input type="button" onclick="ajax_request()" value="Reload" /> <div id="placeholder"><?php include 'random.php';?></div>


Code:
function ajax_request() {   $('#placeholder').html('<p><img src="/images/loader.gif" width="220" height="19" /></p>');   $('#placeholder').load("random.php"); }

But i cant reload 'random.php' in this way , any help pls ?
 
7 comments
Since that is not JS but Jquery did you have this as the first part above the called function.
PHP:
<script src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js"></script>
 
Try this:

PHP:
function ajax_request() {
$.get('random.php', function(data) {
$('#placeholder').html(data);
});
}
You don't need the "onclick" in the HTML by the way, jQuery has a .click() event that you can use on element ID's.
 
I'm impressed Loget, I haven't seen you create a post with code before... Have you been hiding this or have I just been completely oblivious 8-)
 
Hello,
Im copy all files from server and make site clon on localhost, on localhost this method works fine, but on server cant load again random.php files,
So now im found where is problem, im disable permalinks in wordpress on server and bingo! works... but with permalinks cant load... interesting i will try now on google search what is exactly problem
 
Status
Not open for further replies.
Back
Top