DevelopPHP
home Forum gear home

Libraries book

HTML Library CSS Library JavaScript Library PHP Library

Videosbook

PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous

Resourcesbook

Website Hosting
<iframe width="560" height="315" src="http://www.youtube.com/embed/0CMTQtnZ0G0" frameborder="0" allowfullscreen></iframe>
You can embed this video on your blog or web page by copying the video embed code above and pasting it into the source code of your page. Adjust the width and height to specify the size you would like it to display.
Thumb jQuery Ajax PHP Tutorial : Swap out page content on your website
Embed Source - http://www.youtube.com/watch?v=0CMTQtnZ0G0
Publish Date - Mar 21, 2011     Author - Adam Khoury
jQuery Ajax PHP Tutorial : Swap out page content on your website
Learn to use jQuery / Ajax post mechanism to communicate to PHP in order to swap out page content, or access a mysql database, or whatever the hell you want.
Lesson Code
<!-- This is your PHP script... myphpscript.php --> 
          
<?php 
$contentVar 
$_POST['contentVar'];
if (
$contentVar == "con1") {
    echo 
"My default content for this page element when the page initially loads";
} else if (
$contentVar == "con2") {
    echo 
"This is content that I want to load when the second link or button is clicked";
} else if (
$contentVar == "con3") {
    echo 
"Content for third click is now loaded. Any <strong>HTML</strong> or text you wish.";
}
?>

<!-- This is any HTML or PHP file you wish to use -->

<html>
<head>
<script type="text/javascript" src="jQuery-1.5.1.js"></script>
<script language="JavaScript" type="text/javascript">
<!--
function swapContent(cv) {
    $("#myDiv").html('<img src="loader.gif"/>').show();
    var url = "myphpscript.php";
    $.post(url, {contentVar: cv} ,function(data) {
       $("#myDiv").html(data).show();
    });
}
//-->
</script>
<style type="text/css"> 
#myDiv{
    width:200px; height:150px; padding:12px; 
    border:#666 1px solid; background-color:#FAEEC5; 
    font-size:18px;

</style> 
</head>
<body>
<a href="#" onClick="return false" onmousedown="javascript:swapContent('con1');">Content1</a>
<a href="#" onClick="return false" onmousedown="javascript:swapContent('con2');">Content2</a>
<a href="#" onClick="return false" onmousedown="javascript:swapContent('con3');">Content3</a>
<div id="myDiv">My default content for this page element when the page initially loads</div>
</body>
</html>

Home   •   Terms of Use   •   Developer Forums   •   T-Shirts   •   RSS   •   Classroom Chalkboard   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties
©2013 DevelopPHP   |   Navigate to related domains HTML5