Hi,
I have been trying to use AJAX with JQuery in a feedback page I am trying to build. I can get the feedback submitted without going to a new page, but currently I can only see the feedback updated when I refresh the page. I called the feedbackdisplay.php file but it only gets called when loading the page instead of when there is a change in the database. Any ideas why this is the case?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<link rel="stylesheet" type="text/css" href= "widestyle.css" id="style" title="style"/>
<link href='http://fonts.googleapis.com/css?family=Archivo+Narrow' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="jquery-1.7.2.js"> </script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<title>
My homepage
</title>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$('#myForm').ajaxForm(function() {
// attach handler to form's submit event
$('#myForm').submit(function() {
// submit the form
$(this).ajaxSubmit();
// return false to prevent normal browser submit and page navigation
return false;
});
});
$('#list').load("feedbackdisplay.php");
});
</script>
<div id="main">
<div id="nav">
<span class="linkcontainer"><a href="index.html">Home </a></span>
<span class="linkcontainer"><a href="pierscv.html">My CV </a></span>
<span class="linkcontainer"><a href="tutorials.html"> Tutorials </a></span>
<span class="linkcontainer"><a href="feedbackhome.php"> Feedback </a></span>
<a class="linkcontainer contact" href="contact.html"> Contact </a>
</div>
<h1>Feedback </h1>
<div class="set" id="test">
<h2 class="firstsection">Introduction</h2>
<p class="firstpara">
This page is designed as a knowledgebase of different things that I have picked up over the years to do with software and programming.
I have designed this page so that I can use it as a quick reference but also so that anyone can use it to help them.
You will find information on using Microsoft office, useful Javascript I have picked up, HTML5, css and a list of different doctypes
and video editing using Adobe Premiere Elements.<br/><br/>
<strong> If there is any other content you would find useful on this site to do with software and programming then let me know. </strong>
</p>
</div>
<div class="set">
<h2>Feedback form<button class="sh">show/hide </button></h2>
<p class="firstpara">
Please complete the form below to provide your feedback.
</p>
<form action="feedback.php" method="post" id="myForm">
Enter Name: <span style="position:relative; left:20px;"><input type="text" id="text" name="text"/> </span><br/><br/>
Enter feedback: <textarea id="feedback" name="feedback"> Enter Feedback here