Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:04:20+00:00 2026-06-08T00:04:20+00:00

I am trying to create a feature on my website that automatically updates the

  • 0

I am trying to create a feature on my website that automatically updates the database onchange of the textarea below (which is going to be act as a ‘post-it note for reminders’). I am new to ajax, and I was wondering if someone can show me a basic example of how I would make an AJAX call to update my database onChange of the textarea below?

<?php
//Create mysql connect variable
$conn = mysql_connect('samplesource.com', 'example', 'pass');

//kill connection if error occurs
if(!$conn){
    die('Error: Unable to connect.' . '<br>' . mysql_error());
}
//connect to mysql database
mysql_select_db("mydb", $conn);

session_start();
$userid = $_SESSION['id'];

$results = ("SELECT * FROM notes WHERE userid='$userid'");
?>

<html>
<head>
<title>practice</title>
<script src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function() {     
    $(".sometext").change(function(){   
        //make ajax call to update database onChange    
    }); 
}); 
</script>
</head>
<body>

<textarea class="note" style="resize:none; width:300px; height:200px;"> </textarea>

</body>
</html>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:04:22+00:00Added an answer on June 8, 2026 at 12:04 am

    First, you’d need to move your database save script into a new file e.g save.php

    On your <textarea> i’d add

    <textarea onchange="saveChanges(this);"></textarea>
    

    For the javascript save function that’s called when a change is made:

    function saveChanges(object){   
        $.ajax({
            url: 'save.php',
            data: 'content=' + object.value,
            cache: false,
            error: function(e){
                alert(e);
            },
            success: function(response){
                // A response to say if it's updated or not
                alert(response);
            }
        });   
    }
    

    This is a very quick and dirty way of doing it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a somewhat complex sorting feature which neither uses divs nor
I'm trying create a bot which automatically likes Facebook posts. Using Mechanize I can
I am trying to create a feature on my website where users can upload
I'm trying to create a feature that's similar to what Google News does -
I am trying to create a forgot password feature which will expire the link
I am trying to create a feature which essentially amounts to a Facebook style
I'm trying to create a script that will move a feature branch to an
I'm trying to create a feature that both creates a list template and an
I'm trying to create a simple message feature for my website but I couldn't
i'm trying to create a portfolio website using wordpress, each post has view costum

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.