[英]unable to get response of ajax request in symfony2
I am new to symfony2. 我是symfony2的新手。 Basically I want to send a variable
name
to a file named sub.html.php
. 基本上,我想将变量
name
发送到名为sub.html.php
的文件。 I am making an ajax request as following : 我正在发出ajax请求,如下所示:
function onsub()
{
alert(document.getElementById('source').value);
var http=new XMLHttpRequest();
var name="rohit";
http.open("POST", {{path('task1')}}, false);
http.onreadystatechange = function()
{
alert(http.status);
if(http.readyState == 4 && http.status == 200)
{
alert('i m back');
}
else
{
alert('sorry');
}
}
http.send();
return false;
}
I have defined the route of task1
as follow: 我定义了
task1
的路由,如下所示:
task1:
pattern: /task1/
defaults: {_controller:AcmeTaskBundle:Task:task1}
and in TaskController I have defined task1Action as follow: 在TaskController中,我定义了task1Action,如下所示:
public function task1Action()
{
return $this->render('AcmeTaskBundle:Default:sub.html.php');
}
but I am unable to call the sub.html.php file anyhow. 但我还是无法调用sub.html.php文件。 How can I call this file?
我怎么称呼这个文件?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.