Go Back   CodingForums.com > :: Client side development > JavaScript programming > Ajax and Design

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 11-27-2011, 10:03 PM   PM User | #1
Erickk
New to the CF scene

 
Join Date: Nov 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Erickk is an unknown quantity at this point
Ajax Search result, disable other script

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

Last edited by Erickk; 11-27-2011 at 10:19 PM..
Erickk is offline   Reply With Quote
Reply

Bookmarks

Tags
ajax, javascript, php, search

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:18 AM.


Advertisement
Log in to turn off these ads.