我试图将 phonegapp 代码与我的 symfony 网络服务连接起来。我正在通过 ajax 请求从 phonegapp 发送数据,但没有找到如何从 symfony2 控制器接收该数据的任何方法。phone gap 中的代码如下:
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;
}
但是在任一部分执行时都没有收到请求或响应。有没有其他的连接方式?