javascript or ajax UPDATE query

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
revbackup
Forum Commoner
Posts: 29
Joined: Tue Jun 09, 2009 1:52 am

javascript or ajax UPDATE query

Post by revbackup »

Hi guys, I have a code to edit a div tag in place when I click on the text. Now, what I want to do is perform
an UPDATE query in my database when I click outside the div. Considering I have a updatequery.php which
contains the codes to update the database, how will I call that updatequery.php using ajax?


This is my code:

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FANCY EDIT-ON-PLACE</title>
<style>
.input {
    color: #f00;
    background: #00CCCC;
    width: 400px;
}
div button{
    color: #f0f;
}
.style1 {color: #FFFFFF}
.style2 {color: #FFFF00}
</style>
 
<script language="javascript" type="text/javascript" src="jquery-1.2.6.min.js"></script>
<script language="javascript" type="text/javascript" src="editable-1.1.0-extended.js"></script>
<script>
function mouseover()
{
document.getElementById("thediv").style.backgroundColor='blue';
}
function mouseout()
{
document.getElementById("thediv").style.backgroundColor='black';
} 
 
 
$(function(){
    //#
    function begin(){
        this.append('Double Click to submit');
    }
    function end(content){
    //what I should do is to have a code to update the database with the content.current
        alert(content.current)
    }
    $('div.editable').editable({
                        onSubmit:end
                        });
    
                            
});
</script>
</head>
<body bgcolor="#000000">
    <div class="editable style1"  id=thediv onmouseover="mouseover()" onmouseout="mouseout()" >click me to edit</div>
</body>
</html>
 
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: javascript or ajax UPDATE query

Post by jackpf »

I suggest you google an ajax tutorial. There are plenty out there.
Post Reply