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 6869633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:34:57+00:00 2026-05-27T03:34:57+00:00

I am doing a sticky note web site where users can post msg etc

  • 0

I am doing a sticky note web site where users can post msg etc onto post it notes. I am using jQuery UI with PHP. I was hoping to use AJAX to make it responsive but am having some issues with the page updating via ajax.

The main issue is my jQuery appears to only work when the user enters the site for the first time, when they add some info through a form (and to database) my jQuery UI behaviour (i.e. drag and drop, getting attributes and position elements with CSS) stops working until a page refresh. It is like my ajax is passing new looped PHP content and jQuery is no longer recognising the .class I have applied!

Hopefully this or my code makes sense, I am still new to ajax and coding in general.

Main page – pert.php

 <html>
 <header>

 <link rel="stylesheet" href="style.css" type="text/css"/>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript"
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<link rel="stylesheet" type="text/css"
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/themes/base/jquery-ui.css"/>


<script type="text/javascript"
src="js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<script type="text/javascript"
src="js/fancybox/jquery.easing-1.3.pack.js"></script>   

<script type="text/javascript">


jQuery(document).ready(function() {


$("#addtask").submit(function() {

    //$("#form").serialize();

    $.post('update.php', $("#addtask").serialize(),function(data){

        $("#result").html(data); 
    });

    return false; //stop browser refresh

   });


//looping through Post it Notes to apply to all within class
$(".task").each(function(index){

//store x, y from looped php
var x = $(this).attr("x");
var y = $(this).attr("y");

//assign looped php to css
$(this).css("left",x);
$(this).css("top",y);
//attach draggable behaviour
$(this).draggable({
cursor: 'move',
stack: '.post',
opacity: '0.5',
containment: '#container'
});

//store variables x, y and id for database via mouse move and ajax 
$(this).mouseup(function(){
var coord=$(this).position();
var h = $(this).height();
var w = $(this).width();        
var coordLeft = coord.left;
var coordTop = coord.top;
var noteid = $(this).attr("taskid");




})//loop done





})//jquery end

   </script>
   </header>

  <body>





    <h4>Draggable Stickies</h4>


    <!--<p> Click here to <a class = "addimage" href="addimage.html">Add image</a> </p>-->
   <form id="addtask">
Task Desc:<input type="text" name="taskdesc"/>
<input type="submit" value="Enter"/>


    </form>

    <div id="result">

   <?
   include "connectdb.php";
   //looping through stored desc
   $querySticky=mysql_query("SELECT * FROM tasks");
  while($r=mysql_fetch_array($querySticky)){?>
  <div class="task" x="<? echo $r["x"]; ?>" y="<? echo $r["y"]; ?>" 
  id="<? echo $r["taskid"]; ?>">
  x=<? echo $r["x"]; ?> y=<? echo $r["y"]; ?><p><? echo $r["taskdesc"];?></p>
  </div>
  <?}?>


  </div> 


  </body>




  </html>

accessing database – update.php

  <? include("connectdb.php");


 if(ISSET($_POST['taskdesc'])){



 $taskdesc = $_POST['taskdesc'];


$queryinsert1="INSERT INTO tasks(taskdesc)VALUES('$taskdesc')";
$result=mysql_query($queryinsert1);
}

  //for updating coordinates in database not in use y
  if(ISSET($_POST['taskid'])){

 $x = $_POST['x'];
 $y = $_POST['y'];
 $id = $_POST['taskid'];


$addxyquery="UPDATE tasks SET x = '$x', y ='$y' WHERE taskid='$id'";

$result=mysql_query($addxyquery);
}




 //looping through stored desc for updated results
$querySticky=mysql_query("SELECT * FROM tasks");
while($r=mysql_fetch_array($querySticky)){?>
<div class="task" x="<? echo $r["x"]; ?>" y="<? echo $r["y"]; ?>" id="<? echo $r["taskid"]; ?>">
x=<? echo $r["x"]; ?> y=<? echo $r["y"]; ?><p><? echo $r["taskdesc"];?></p>
</div>
<?}?>
  • 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-05-27T03:34:57+00:00Added an answer on May 27, 2026 at 3:34 am

    When the Ajax call returns, you set

    $("#result").html(data); 
    

    But then there is new html in the result-div which isn’t draggable anymore.
    You should execute the javascript to make things draggable again, after the Ajax call.

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

Sidebar

Related Questions

Tried doing http://davidwparker.com/2008/09/17/site-wide-announcements-in-rails-using-jquery-jgrowl/ Am really bad with JS. Think I am messing up on
I've been using this snippet of jQuery to get a sticky footer: if($(document.body).height() <
Doing odd/even styling with jQuery is pretty easy: $(function() { $(.oddeven tbody tr:odd).addClass(odd); $(.oddeven
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing some jquery animation. I have certain divs set up with an attribute of
I'm doing an animate with JQuery UI. I've go an icon which I want
We are looking at doing a 'version 2' of our web application that is
I have a fairly straightforward set of php forms that take users through a
Note: I've only been using Objective-C for a week. Here's my end goal: I
I'm doing a flex application that has tons of screens (each very different, can't

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.