I'm trying to create a jQuery script that will allow me to implement livesearch. So far, all I've got on the screen is nothing, nothing is showing up and I have no idea what's wrong. Any ideas?
javascript:
function searchMembers() {
document.body.style.cursor = "wait";
var gradeMenu = document.getElementById("grade");
var gradeValue = gradeMenu.options[gradeMenu.selectedIndex].text;
var firstNameValue = document.getElementById("firstName").value;
var lastNameValue = document.getElementById("lastName").value;
var studentIDValue = document.getElementById("studentID").value;
$.post (
"search.php",
{'firstName':firstNameValue, 'lastName':lastNameValue, 'grade':gradeValue, 'stID':studentIDValue},
function(data) {
document.getElementById("searchOutput").innerHTML=data;
document.body.style.cursor="auto";
}
);
}
$(document).ready(function() {
var loc = (String)(window.location);
if(loc.indexOf("view_membersWithSearch.php") > 0)
searchMembers();
});
search.php:
if(isset($_POST['firstName'])) {
$firstNameValue = $_POST['firstName'];
}
if(isset($_POST['lastName'])) {
$lastNameValue - $_POST['lastName'];
}
if(isset($_POST['grade'])) {
$gradeValue = $_POST['grade'];
}
if(isset($_POST['stID'])) {
$studentIDValue = $_POST['stID'];
}
view_membersWithSearch.php:
<div id="searchOutput"></div>
Edit: jQuery is included, I placed it at the bottom of view_membersWithSearch.php. The problem is after I click on a menu or insert text to update the search, nothing happens. The area where the results are supposed to be placed is blank. By default, I'm also supposed to have all the results displayed by default, but that too is blank.
Edit 2: Firebug gives this: The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must to be declared in the document or in the transfer protocol.