Home » Php » AJAX Call to PHP script gives me 500 Internal Server Error?

AJAX Call to PHP script gives me 500 Internal Server Error?

Posted by: admin July 12, 2020 Leave a comment


I make an AJAX request like so using JQuery:

  type: "GET",
  url: "getvideo.php",
  data: 'videoid=' + vid,

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

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

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 named it “getvideo.php” since I have PHP 5.2.6 installed only.

Please help


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

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.


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. I should have tried that first.

yum install php-xml
yum install php-xmlrpc
How to&Answers:

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.


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.


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.


I had a similar problem, but the solution was different. Check to see if you have uploaded all files referenced in the PHP code. I found out the file I was calling through ajax had references to classes whose definition files were missing, and the server returned a 500 Internal server error for that.


probably you just have a php code error copy and past the (url)
And will show you the error fix it and all should be okay
good luck