启用视图自定义模块会在Drupal 7上导致Ajax HTTP错误

时间:2013-02-05 04:02:44

标签: ajax drupal drupal-7 views

我正在开发一个自定义模块,它将描述Views模块的外部表。在我的模块文件夹中,我有所需的mymodule.views.inc文件。但是,每当存在此文件并启用我的自定义模块时,当我使用具有Ajax的站点功能(任何旋转雏菊触发此功能)时,Drupal会不断提供Ajax HTTP Error弹出窗口。在弹出Ajax Error之后,弹出窗口始终包含mymodule.views.inc中的模块代码。奇怪的是每次加载首页时,mymodule.views.inc中的PHP代码总是显示在首页的顶部。

我在SO和其他网站上看到了很多这个问题,但大多数情况下它可以追溯到更新的jquery.js文件或php.ini设置,这将使脚本有更多的时间来运行。到目前为止,这些修复都没有奏效。我现在唯一能让它消失的方法是禁用我的自定义模块,或者将mymodule.views.inc重命名为其他内容。

以下是该消息的示例(不是逐字复制,因为我无法从Chrome中的这些警报消息中复制)。

An AJAX HTTP error occurred.
HTTP Result Code: 200
Debugging information follows.
Path: /?q=admin/structure/views/view/viewiamtryingtocreate/preview/page/ajax
StatusText: parseerror
ResponseText: /*
* header file to my mymodule.views.inc
* file I wrote
*/

//more php code follows

//lots of unicode characters intermittently show up in my source code
\u003C\/div\u003E\n...

//source code continues with lots of unicode characters, not sure what's at the bottom because the alert box is bigger than my screen and I can't scroll on it

还有其他人知道会发生什么吗?

2 个答案:

答案 0 :(得分:0)

此错误是由drupalforfirebug引起的,禁用drupal for firebug应该有所帮助。或者这个patch应该有用。

答案 1 :(得分:0)

找到它。隐藏在mymodule.views.inc顶部的语法错误。在打开PHP标记之前有一些奇怪的格式。不知道为什么php --syntax-check mymodule.php没有捕获它(我将mymodule.views.inc复制到mymodule.php以便我可以在其上运行语法检查器。)