Davidammit Posted August 16, 2008 Share Posted August 16, 2008 I'm trying to get a website going that will have a search on every page. I got the PHP part working...but now the JavaScript Part doesn't even want to run. I bet I screwed up somewhere. To test if it was a problem with the server I moved another piece of JavaScript that I knew would work to its own file, so now I know that its just the code. But then I tested it with code straight from a tutorial site, to see if that would run, and it didn't either, so maybe the site isn't compatible with ResponseXML requests? Instead of posting all the code here, I think I'll just link to the source files. http://weareotaku.x10hosting.com/ http://weareotaku.x10hosting.com/search.js http://weareotaku.x10hosting.com/search.php The only searchable things in the database right now are rosario + vampire to I just made it as a test, and I know that the PHP does work, cuz it returns the proper XML for what I need the JavaScript to do. Thank you in advance for any help. Link to comment https://forums.phpfreaks.com/topic/120013-solved-i-must-be-messing-up-on-the-javascript-portion-of-this-ajax/ Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 I momentarily forgot PHP was serverside only. Here's the code <?php $q=$_GET["search"]; $con = mysql_connect('localhost', 'waotaku_search', 'abc123'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("waotaku_anime", $con); $sql="SELECT title, link, embed, added, MATCH(title, keywords) AGAINST('" . $q . "') AS relevance FROM animelist WHERE episode=0"; $result = mysql_query($sql); echo '<?xml version="1.0" encoding="ISO-8859-1"?>'; for($row = mysql_fetch_array($result); $row != null; $row = mysql_fetch_array($result)) { echo '<person>'; echo "<title>" . $row['title'] . "</title>"; echo "<link>" . $row['link'] . "</link>"; echo "<embed>" . $row['embed'] . "</embed>"; echo "<added>" . $row['added'] . "</added>"; echo "</person>"; } mysql_close($con); ?> Link to comment https://forums.phpfreaks.com/topic/120013-solved-i-must-be-messing-up-on-the-javascript-portion-of-this-ajax/#findComment-618278 Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 well I finally fixed that problem on my own, but now its not carrying out the document.getElementById("searchresults").innerHTML=xmlDoc.getElementsByTagName("title")[0].childNodes[0].nodeValue; Link to comment https://forums.phpfreaks.com/topic/120013-solved-i-must-be-messing-up-on-the-javascript-portion-of-this-ajax/#findComment-618436 Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 i've narrowed it down to the part that refers to the xmlDoc. Since when i just do the document.getElementById("searchresults").innerHTML="OMFG WHY WON'T U WORK!!!"; it displays it. Link to comment https://forums.phpfreaks.com/topic/120013-solved-i-must-be-messing-up-on-the-javascript-portion-of-this-ajax/#findComment-618448 Share on other sites More sharing options...
Davidammit Posted August 17, 2008 Author Share Posted August 17, 2008 well I found a way around the problem by formatting the text on the PHP side and useing responseText instead of responseXML...but this may prove to be a problem later. Link to comment https://forums.phpfreaks.com/topic/120013-solved-i-must-be-messing-up-on-the-javascript-portion-of-this-ajax/#findComment-618749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.