gpt4 book ai didi

javascript - jsrouting-bundle symfony 错误

转载 作者:行者123 更新时间:2023-11-28 00:51:23 25 4
gpt4 key购买 nike

我已经安装了 jsrouting-bundle,这是我的代码:

Javascript:

$(document).ready(function () {
$(".pmcontents").hide();
$(".pmbox").click(function () {
$(this).css("font-weight", "normal");
$(this).next().toggle();
var myValue = $('this').attr('id');
var DATA = 'sentValue=' + myValue;
$.ajax({
type: "POST",
url: Routing.generate('isread'),
data: DATA,
cache: false,
success: function (data) {
alert("database has been updated");

}
});
});

});

Controller :

public function isreadAction() {
$request = $this->get('request');
if ($request->isXmlHttpRequest()) {
var_dump($request->request->get('sentValue'));
$em = $this->getDoctrine()->getEntityManager();
$pm = $this->getDoctrine()
->getRepository('LoginLoginBundle:Privatemessage')
->findBypmid($request->request->get('sentValue'));

$pm->setIsRead(true);
$em->flush();
return new Response();
}
}

路由:

isread:
path: /game/isread
defaults: { _controller: LoginLoginBundle:Default:isread }
requirements:
_method: POST

我在控制台中收到以下错误:µ

Error: The route "isread" does not exist.

因此,除了下图中出现的错误之外,这应该是我的问题,但我不知道我做错了什么。

Errors

最佳答案

您需要公开路线,例如:

isread:
path: /game/isread
defaults: { _controller: LoginLoginBundle:Default:isread }
requirements:
_method: POST
options: # < add these two
expose: true # < lines

» manual

关于javascript - jsrouting-bundle symfony 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26740145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com