Skip to content
WJunction - Webmaster Forum

Reload content without page refresh

  • AmN Thread starter AmN
  • Start date Start date
  • 7 Replies
  • 4,871 Views
Status
Not open for further replies.

AmN

Established Member
342
2009
41
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

iframe is fool proof. set iframe href to whatever you want (same url to reload) using javascript.
 
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>
 
Sure, and works fine with other files, but i cant call random.php in that way, simple cant load
 
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.

About the author

AmN
Established Member · Joined
342
Messages
41
Reactions
28
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom