I have a search function to display all of the data into the table. I used two js which is tablesort.js and paginate.js to sort my table. Here the problem, I used ajax to call the result page, however the javascript inside the page could not run. Hence my table cannot be sort.
To get search result
PHP Code:
<h3>Search Results</h3>
<div id="msg"> </div>
<div id="search-result">
ajax_framework.js
Code:
function createObject() {
var request_type;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
request_type = new ActiveXObject("Microsoft.XMLHTTP");
} else {
request_type = new XMLHttpRequest();
}
return request_type;
}
var http = createObject();
/* -------------------------- */
/* SEARCH */
/* -------------------------- */
function searchNameq() {
searchq = encodeURI(document.getElementById('searchq').value);
type = encodeURI(document.getElementById('type').value);
document.getElementById('msg').style.display = "block";
document.getElementById('msg').innerHTML = "Searching for <strong>" + searchq+"";
// Set te random number to add to URL request
nocache = Math.random();
http.open('get', 'in-search.php?name='+searchq+'&type='+type+'&nocache = '+nocache);
http.onreadystatechange = searchNameqReply;
http.send(null);
}
function searchNameqReply() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById('search-result').innerHTML = response;
}
}
Result Page which consist 2 js
PHP Code:
<script type="text/javascript" src="js/tablesort.js"></script>
<script type="text/javascript" src="js/paginate.js"></script>
Thanks