Ajax 返回的数据不带 } 结尾



我在使用 ajax 时遇到了一个斯坦格问题。我的成功数据被截断。

那里有我的 ajax 函数:

$.ajax({
    type: "POST",
    url: url, //url to connexion function
    data: {form: $('#jforms_users_connexion').serializeArray()},
    success: function(data)
    { 
      alert("enter success");
    }});

有我的php函数

function connexion()
{ 
  $rep = $this->getResponse('json'); //my php will return an json array
  $rep->data = array("data" => "toto");
  jLog::dump($rep);
  return $rep;
}

转储给这个

default jResponseJson::__set_state(array(

'data' => 
  array (
    'data' => 'toto',
  ),
   '_type' => NULL,
   '_httpHeaders' => 
  array (
  ),
   '_httpHeadersSent' => false,
   '_httpStatusCode' => '200',
   '_httpStatusMsg' => 'OK',
   '_outputOnlyHeaders' => false,
   'httpVersion' => '1.1',
   'forcedHttpVersion' => false,
))

但是在Firebug上,响应是{"data":"tt"

没有"}",警报也不起作用

有什么想法吗?

你的 ajax 代码有一点语法错误-

 $.ajax({
   type: "POST",
   url: url, //url to connexion function
   data: {form: $('#jforms_users_connexion').serializeArray()},
   success: function(data)
   { 
    alert("enter success");
   }
 });

您缺少结束标记"});"。

相关内容

最新更新