Jump to content

[SOLVED] I must be messing up on the JavaScript portion of this AJAX


Davidammit

Recommended Posts

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.

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);
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.