AJAX调用PHP脚本给我500内部服务器错误?

时间:2021-11-19 01:26:27

I make an AJAX request like so using JQuery:

我使用JQuery制作一个AJAX请求:

$.ajax({
  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:

我用firebug告诉我发生了什么,它告诉我发生了500内部服务器错误?以下是相关脚本的一部分:

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

我对其他脚本使用相同的AJAX调用,它们很好。我在另一台服务器上使用过这些脚本,它很好,除了在另一台服务器上,文件命名为“getvideo.php5”,而在这里我把它命名为“getvideo.php”,因为我只安装了PHP 5.2.6。

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/

[Wed Feb 11 20:48:17 2009] [错误] [client xx.xx.xxx.xxx] PHP致命错误:在/ var / www / html / library / Zend / Gdata / App中找不到类'DOMDocument'。 php在734行,referer:http://xx.xx.xx.xxx/

I hid my IP. At that line:

我藏了我的IP。那条线:

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.

但我不应该玩那个吧?在任何情况下,该类不作为脚本存在,并且在该脚本中不作为类存在。我在我的其他服务器上使用这个相同的图书馆。它也缺少???这是我从Youtube API zip文件夹下载的内容。

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

这是一个全新的服务器,它安装了最少的PHP。我缺少PHP dom功能。快速安装修复了这个问题。谢谢你提醒我查看日志。我应该先尝试一下。

yum install php-xml
yum install php-xmlrpc

6 个解决方案

#1


9  

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.

尝试在浏览器中自己手动执行调用(同样的事情)并查看返回的内容。如果没有返回任何内容并且您收到500内部服务器错误,则需要查看日志并查看导致此错误发生的原因。

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.

还要确保您正在对正确的域进行ajax调用。如果您尝试呼叫您的域,则呼叫每次都会失败。

#2


2  

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

什么? .php5?我不知道你的apache配置(假设你甚至使用它),但.php适用于所有版本的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.

无论如何,尝试直接访问该URL并查看会发生什么,这不应该与Ajax有任何关系。另请查看您的Web服务器日志。

#3


0  

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.

确保正确设置权限。刚刚在justhost.com服务器上遇到同样的问题将我的php脚本的权限设置为0644,一切都很好。

#4


0  

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.

我有类似的问题,但解决方案不同。检查是否已上载PHP代码中引用的所有文件。我发现我通过ajax调用的文件引用了缺少定义文件的类,并且服务器为此返回了500内部服务器错误。

#5


0  

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

可能你只是有一个PHP代码错误副本和过去的(网址)并将显示错误修复它,所有应该没关系好运

#6


-5  

I have same this error. Firebug will tell you 500 internal server error.

我有同样的错误。 Firebug会告诉你500内部服务器错误。

#1


9  

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.

尝试在浏览器中自己手动执行调用(同样的事情)并查看返回的内容。如果没有返回任何内容并且您收到500内部服务器错误,则需要查看日志并查看导致此错误发生的原因。

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.

还要确保您正在对正确的域进行ajax调用。如果您尝试呼叫您的域,则呼叫每次都会失败。

#2


2  

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

什么? .php5?我不知道你的apache配置(假设你甚至使用它),但.php适用于所有版本的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.

无论如何,尝试直接访问该URL并查看会发生什么,这不应该与Ajax有任何关系。另请查看您的Web服务器日志。

#3


0  

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.

确保正确设置权限。刚刚在justhost.com服务器上遇到同样的问题将我的php脚本的权限设置为0644,一切都很好。

#4


0  

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.

我有类似的问题,但解决方案不同。检查是否已上载PHP代码中引用的所有文件。我发现我通过ajax调用的文件引用了缺少定义文件的类,并且服务器为此返回了500内部服务器错误。

#5


0  

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

可能你只是有一个PHP代码错误副本和过去的(网址)并将显示错误修复它,所有应该没关系好运

#6


-5  

I have same this error. Firebug will tell you 500 internal server error.

我有同样的错误。 Firebug会告诉你500内部服务器错误。