I have this code.
var book = document.getElementById(\'txtBook\').value;
switch(book.toUpperCase())
{
case \"GEN\": var bk = \"101\"; break;
You need to use ajax.
$.get('getbook.php', {book: $('#txtBook').val()}, function(data) {
// here you get your data and deal it
});
The simplest way is applying ajax.
Serve script(getbook.php):
$bookId = $_POST['book'];
//do some search stuff
$rows = getBookInfo($bookId);
$result = array('searchResult' => $rows);
header('Content-Type: application/json');
echo json_encode($result);
Client script(remeber to include js for jquery):
postData = {book: bookId};
$.ajax({
type: 'POST',
url: '/getbook.php',
data: postData,
dataType: 'JSON',
success: function (jsonObj) {
//use jsonObj.serachResult as array
}
});