English 中文(简体)
Json代码与AJAX检索是无法分开的。
原标题:Json code retrieved with AJAX is unparsable

页: 1

我写了简单的json jquery php代码,以帮助理解json的想法,但不要工作,请帮助我。 (千美元) 我写了_Post,提交,点击功能等,因为我没有与它合作,因此我切断了该法典以找到问题。

用户输入了意见.html,应当有一个带有价值的警示箱:问题在于用户没有进入警示箱。

<>view.html

<html>
<head>
<script type="text/javascript" 
        src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">
</script>
<script type="text/javascript">
  $(document).ready(function () {
      $.ajax({
          url:  controller.php ,
          type:  post ,
          dataType:  json ,
          success: function (data) {
              alert(data["userdata"]["first"]);
          }
      });
  });​
</script>
</head>
<body>
</body>
</html>

Controller.php:

<?php
  $arr=array();
  $arr[ userdata ][ first ]= Dan ;
  echo json_encode($arr);
?>

救助

最佳回答

敬请在你的PHP档案中添加正确的JSON头盔。

header( Cache-Control: no-cache, must-revalidate );
header( Expires: Mon, 26 Jul 1997 05:00:00 GMT );
header( Content-type: application/json );
问题回答

您将检查一下你ache的_形——安全环境。 这可能造成你503个暂时无法提供的服务

感谢Jan 我发现问题:我的当地公有服务器在安装工作起步时没有工作(因为一味界定了被zen的社区服务器的密码)。





相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签