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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.