我试图将phonegapp代码与我的symfony webservice连接起来。我通过ajax请求从phonegapp发送数据,但没有找到任何方法来从symfony2控制器接收数据。电话差距中的代码如下:
function login()
{
var email = $("#userid").val();
var pwd = $("#password").val();
jQuery.ajax({
type:'POST',
url: 'http://external.apostle.digibiz.com/web/app_dev.php/api/ajax',
data: {tag:'ULogin',u_email:email,password:pwd},
success: function(response)
{
var jsObject = JSON.parse(response);
alert(jsObject);
if(jsObject==undefined)
{
alert('undefined');
}
else
{
var result = jsObject[0].success;
if(jsObject[0].success == 1)
{
alert('success');
}
else
{
alert('not varified');
}
}
}
});
}
the code in my symfony2 controller is written as :
public function ajaxAction(Request $request)
{
$data = $request->request->get('tag');
$encoders = array( new JsonEncoder());
$normalizers = array(new GetSetMethodNormalizer());
$serializer = new Serializer($normalizers, $encoders);
// $jsonContent = $serializer->serialize("inserted successfully", 'json');
$headers = array(
'Content-Type' => 'application/json'
);
$response = new Response($data, 200, $headers);
return $response;
}
但是在任一部分执行时都没有收到请求或响应。还有其他方法可以连接吗?