A community in which webmasters can ask for help with topics such as PHP coding , MySQL , IT jobs, web design, IT security.
Current location:homephp forumphp talk in 2008 yearHow load a PHP page in the same window in jQuery - page 1
User InfoPosts
How load a PHP page in the same window in jQuery#1
I have a PHP file, Test.php, and it has two functions:

<?php
echo displayInfo();
echo displayDetails();
?>


JavaScript:

<html>
...
<script type="text/javascript">
$.ajax({
type:'POST',
url: 'display.php',
data:'id='+id ,
success: function(data){
$("#response").html(data);
}
});
</script>
...

<div id="response">
</div>
</html>


It returns the response from jQuery. The response shows as <a href=Another.php?>Link</a>. When I click the Another.php link in test.php, it loads in another window. But I need it to load the same <div> </div> area without changing the content of test.php, since it has displayInfo(), displayDetails(). Or is it possible to load a PHP page inside <div> </div> elements?

How can I tackle this problem?

posted date: 2008-12-16 02:01:00


Re: How load a PHP page in the same window in jQuery#2
I had made out the solution of this problem. click to view my topic...

hope that hepls.

posted date: 2008-12-16 02:01:01


Re: How load a PHP page in the same window in jQuery#3
If I understand correctly, you'd like for the a link to cancel navigation, but fire the AJAX function?In that case:$("#mylink").click(function() {$.ajax({ type: "POST", url: "another.php", data: {id: "somedata"}, function(data) {$("#response").html(data);});return false;});

posted date: 2008-12-16 02:10:00


Re: How load a PHP page in the same window in jQuery#4
You could just use MooTools and class Request.HTML.

posted date: 2008-12-16 13:27:00


Re: How load a PHP page in the same window in jQuery#5
Krof is correct,One possible unwanted behavior of this however is that it will query the data every time the link is clicked. You can set the event to only call the ajax query once by using one.$("#mylink").one('click', function() { // ajax call return false;});Don't forget to set href="javascript:{}" in your link so after the event is fired once the link wont do anything;

posted date: 2008-12-16 13:47:00


Re: How load a PHP page in the same window in jQuery#6
Actually the href="" part isn't needed if you cancel event bubbling by returning false. Although I think it does help if you want to avoid having the outline drawn around a elements (if I remember correctly).

posted date: 2009-01-14 06:16:00


select page: « 1 »
Copyright ©2008-2017 www.momige.com, all rights reserved.