从jQuery加载symfony 2目录中的php文件

时间:2023-02-06 13:26:22

I have this line of code (jQuery) in a twig file inside a bundle( BundleDir/Bundle/views/mapname/index.html.twig) :

我在一个包内的twig文件中有这行代码(jQuery)(BundleDir / Bundle / views / mapname / index.html.twig):

$('#datacount').load('getDataCount.php');

my question is where do i need to put getDataCount.php file in the symfony 2 directory. It keeps saying that this file can't be found..

我的问题是我需要将getDataCount.php文件放在symfony 2目录中。它一直说这个文件找不到..

Thanks !

谢谢 !

1 个解决方案

#1


6  

jQuery.load() performs an HTTP GET request, in your case it's GETting 'getDataCount.php'.

jQuery.load()执行HTTP GET请求,在你的情况下它是GETting'getDataCount.php'。

Either you really (really, really) want that file to standalone, and you can just put a "/" and move the file in your web folder

你真的(真的,真的)要求该文件是独立的,你只需要放一个“/”并将文件移动到你的web文件夹中

$('#datacount').load('/getDataCount.php');

app/..
src/..
web/getDataCount.php

or you want it to be a symfony controller, and you must use routes and controllers as defined in the Book http://symfony.com/doc/current/book/routing.html

或者你希望它是一个symfony控制器,你必须使用书http://symfony.com/doc/current/book/routing.html中定义的路由和控制器

Cheers

干杯

#1


6  

jQuery.load() performs an HTTP GET request, in your case it's GETting 'getDataCount.php'.

jQuery.load()执行HTTP GET请求,在你的情况下它是GETting'getDataCount.php'。

Either you really (really, really) want that file to standalone, and you can just put a "/" and move the file in your web folder

你真的(真的,真的)要求该文件是独立的,你只需要放一个“/”并将文件移动到你的web文件夹中

$('#datacount').load('/getDataCount.php');

app/..
src/..
web/getDataCount.php

or you want it to be a symfony controller, and you must use routes and controllers as defined in the Book http://symfony.com/doc/current/book/routing.html

或者你希望它是一个symfony控制器,你必须使用书http://symfony.com/doc/current/book/routing.html中定义的路由和控制器

Cheers

干杯