views:

3848

answers:

5

Hi

I make an AJAX request like so using JQuery:

$.ajax({
       type: "GET",
       url: "getvideo.php",
       data: 'videoid=' + vid,

I use firebug to tell me whats going on and it tells me a 500 internal server error has occurred? wtf Here is part of the script concerned:

$videoid = $_GET['videoid'];
$get = new youtubeAPI();
$get->getVideoAPI($videoid);

class youtubeAPI extends Exception {

function getVideoAPI($videoid){

    if(isset($videoid)){

     $clientLibraryPath = 'library';
     $oldPath = set_include_path(get_include_path().PATH_SEPARATOR.$clientLibraryPath);

     require_once 'Zend/Loader.php'; // the Zend dir must be in your include_path

I use the same AJAX call to other scripts and they are fine. I have used these scripts on another server and it was fine except on the other server the file is named "getvideo.php5" whereas here I name it "getvideo.php" since I have PHP 5.2.6 installed only.

Please help

UPDATE

This is the error:

[Wed Feb 11 20:48:17 2009] [error] [client xx.xx.xxx.xxx] PHP Fatal error:  Class 'DOMDocument' not found in /var/www/html/library/Zend/Gdata/App.php on line 734, referer: http://xx.xx.xx.xxx/

I hid my IP. At that line:

 public static function importString($string, $className='Zend_Gdata_App_Feed')
    {
        // Load the feed as an XML DOMDocument object
        @ini_set('track_errors', 1);
        $doc = new DOMDocument(); //LINE 734
        $success = @$doc->loadXML($string);
        @ini_restore('track_errors');

But I shouldn't be playing around with that right? In any case, that class doesn't exist as a script and doesn't exist in that script as a class. I AM MAKING USE OF THIS SAME LIBRARY IN MY OTHER SERVER. It is also missing that too??? This is what I downloaded from the Youtube API zip folder.

SOLVED

This was a brand new server and it had minimal PHP installed. I was missing PHP dom functions. A quick install fixed this problem. Thanks for reminding me to look at the logs. Should of been my first try.

yum install php-xml
yum install php-xmlrpc
+2  A: 

What? .php5 ? I don't know your apache configuration (given you're even using it), but .php will work for all versions of PHP.

Anyway, try to directly access that URL and see what happens, this shouldn't have anything to do with Ajax. Also take a look at your web-server logs.

Luca Matteis
Some crappy hosts running php4/php5 side by side on the same domain are using .php as php4 and .php5 for php5. It's ghetto lol.
Syntax
My old host told me to rename php scripts to PHP5 if i wanted to make use of PHP version 5 since I needed Exceptions. This is normal. It worked perfectly on the other server but on this server it doesn't! It does have PHP 5.2.6 installed.
Abs
lol ghetto...btw...its got nothing to do with crappy hosts. This one is very reputable it just took them time to switch from 4 to 5.
Abs
Generally hosts allow 1 or the other. Running them side by side can cause side affects when people try to intermix the two. Say require('mypage.php'); inside of myOtherPage.php5 - it is ghetto :) not trying to diss your host.
Syntax
+3  A: 

Try executing the call manually yourself in your browser (its the same thing) and see what gets returned. If nothing gets returned and you get a 500 internal server error, you need to then review your logs and see whats causing this error to happen.

Also make sure you are making the ajax call to the proper domain. If you try calling out of your domain the call will fail every time.

Syntax
I get returned a blank page - what does that mean? I make previous AJAX calls and they go the same server but this one just returns a 500?? What could it possibly be?
Abs
Check your web-server logs.
Luca Matteis
Abs, as luca has stated your logs should reveal the problem. There are logs for apache and logs for php depending on your setup. Review both, you may have be overlooking something.
Syntax
+2  A: 

What does the error log of the server say?

schmilblick
A: 

i have same this error when use jquery call php script, i don't know that error of server or my php code. You can see this link changtraingheo.byethost22.com/ , in the column left, you look at box "Chia Sẻ Nhanh" , enter some value and submit form, Firebug will tell you 500 internal server error. But also this source on another host work well.

A: 

Make sure permissions are set correctly. Just had the same problem on a justhost.com server Set permissions on my php script to 0644 and all is well.

Jacob