CakePHP Ajax请求未进入内部服务器错误

CakePHP Ajax请求未进入内部服务器错误,php,jquery,ajax,cakephp,Php,Jquery,Ajax,Cakephp,我只是想用CakePhp测试ajax表单提交。我已经写了下面的代码。但是ajax不起作用 chrome中的错误: POSThttp://localhost/john/Frontends/AjaxFormSubmit500(内部服务器错误) 查看文件 echo $this->Form->input('appendedInputButton', array('id'=>'url','name' => 'AjaxFormSubmit', 'type' =&g

我只是想用CakePhp测试ajax表单提交。我已经写了下面的代码。但是ajax不起作用

chrome中的错误: POST
http://localhost/john/Frontends/AjaxFormSubmit
500(内部服务器错误)

查看文件

 echo $this->Form->input('appendedInputButton',
         array('id'=>'url','name' => 'AjaxFormSubmit', 'type' => 'text')); 

 echo $this->Form->button('Convert',
         array('id' => 'Convert', 'type' => 'button'));
2013-08-13 13:41:43 Error: [MissingControllerException] Controller class JsController could not be found.
Exception Attributes: array (
  'class' => 'JsController',
  'plugin' => NULL,
)
Request URL: /john/js/jquery-1.10.1.min.map
Stack Trace:
#0 G:\wamp\www\john\app\webroot\index.php(111): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-08-13 13:42:01 Error: [MissingViewException] View file "G:\wamp\www\john\app\View\Frontends\Ajax_Form_Submit.ctp" is missing.
Exception Attributes: array (
  'file' => 'G:\\wamp\\www\\john\\app\\View\\Frontends\\Ajax_Form_Submit.ctp',
)
Request URL: /john/Frontends/AjaxFormSubmit
Stack Trace:
#0 G:\wamp\www\john\lib\Cake\View\View.php(468): View->_getViewFileName(NULL)
#1 G:\wamp\www\john\lib\Cake\Controller\Controller.php(948): View->render(NULL, NULL)
#2 G:\wamp\www\john\lib\Cake\Routing\Dispatcher.php(194): Controller->render()
#3 G:\wamp\www\john\lib\Cake\Routing\Dispatcher.php(162): Dispatcher->_invoke(Object(FrontendsController), Object(CakeRequest), Object(CakeResponse))
#4 G:\wamp\www\john\app\webroot\index.php(111): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
jQuery

$(document).ready(function () {

    $('#Convert').on({
        'click': function () {
            var urlVal = $("#url").val();
            if (urlVal == '' || urlVal == 0) {
                $("#url").focus();
                return false;
            }

            $.ajax({
                url: 'http://localhost/john/Frontends/AjaxFormSubmit',
                cache: false,
                type: 'POST',
                success: function (data) {
                    alert(data);
                }
            });
        }
    });
});
控制器

App::uses('AppController', 'Controller');

class FrontendsController extends AppController {

    public $name = 'Frontends';
    public $uses = array();
    public $components = array('RequestHandler');
    public $helpers = array('Html', 'Form');


    public function index() {
        $this - > layout = 'frontend_index_layout';
    }

    public function AjaxFormSubmit() {
        echo "Receiving Via Ajax";
    }
}
错误日志文件

 echo $this->Form->input('appendedInputButton',
         array('id'=>'url','name' => 'AjaxFormSubmit', 'type' => 'text')); 

 echo $this->Form->button('Convert',
         array('id' => 'Convert', 'type' => 'button'));
2013-08-13 13:41:43 Error: [MissingControllerException] Controller class JsController could not be found.
Exception Attributes: array (
  'class' => 'JsController',
  'plugin' => NULL,
)
Request URL: /john/js/jquery-1.10.1.min.map
Stack Trace:
#0 G:\wamp\www\john\app\webroot\index.php(111): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#1 {main}
2013-08-13 13:42:01 Error: [MissingViewException] View file "G:\wamp\www\john\app\View\Frontends\Ajax_Form_Submit.ctp" is missing.
Exception Attributes: array (
  'file' => 'G:\\wamp\\www\\john\\app\\View\\Frontends\\Ajax_Form_Submit.ctp',
)
Request URL: /john/Frontends/AjaxFormSubmit
Stack Trace:
#0 G:\wamp\www\john\lib\Cake\View\View.php(468): View->_getViewFileName(NULL)
#1 G:\wamp\www\john\lib\Cake\Controller\Controller.php(948): View->render(NULL, NULL)
#2 G:\wamp\www\john\lib\Cake\Routing\Dispatcher.php(194): Controller->render()
#3 G:\wamp\www\john\lib\Cake\Routing\Dispatcher.php(162): Dispatcher->_invoke(Object(FrontendsController), Object(CakeRequest), Object(CakeResponse))
#4 G:\wamp\www\john\app\webroot\index.php(111): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#5 {main}
阅读您的错误日志:

错误:[MissingViewException]查看文件 缺少“G:\wamp\www\john\app\View\Frontends\Ajax\u Form\u Submit.ctp”。 异常属性:数组('file'=> 'G:\wamp\www\john\app\View\Frontends\Ajax\u Form\u Submit.ctp',) 请求URL:/john/Frontends/AjaxFormSubmit

问题很清楚:您的视图文件丢失了,所以请创建它。我不知道你期望从中得到什么样的答案,但你所做的是错误的。如果要返回json


如果你真的想回显一个字符串,你需要调用$this->_stop();回声过后。但是,实际上,您不应该返回一个无意义的字符串,而应该返回某种json对象,其中包含正确的消息,可能还有错误代码和状态,以便javascript可以处理响应。

检查您的error.log并将其粘贴到此处。@burzum:我已经粘贴了error.log..在这些情况下,请始终检查您的错误日志以及其他信息重要提示:阅读它。这里解释了你问题的原因。