小编Tom*_*Tom的帖子

无法使用jQuery AJAX将null传递给服务器.在服务器上收到的值是字符串"null"

我正在转换javascript/php/ajax应用程序以使用jQuery来确保与Firefox以外的浏览器兼容.

我使用jQuery的ajax函数传递true,false和null值时遇到问题.

Javascript代码:

$.ajax
(
   {
      url     : <server_url>,
      dataType: 'json',
      type    : 'POST',
      success : receiveAjaxMessage,
      data:
      {
         valueTrue : true,
         valueFalse: false,
         valueNull : null
      }
   }
);
Run Code Online (Sandbox Code Playgroud)

PHP代码:

var_dump($_POST);
Run Code Online (Sandbox Code Playgroud)

服务器输出:

array(3) {
  ["valueTrue"]=>
  string(4) "true"
  ["valueFalse"]=>
  string(5) "false"
  ["valueNull"]=>
  string(4) "null"
}
Run Code Online (Sandbox Code Playgroud)

问题是null,true和false值正在转换为字符串.

当前使用的Javascript AJAX代码正确传递null,true和false,但仅适用于Firefox.

有谁知道如何使用jQuery解决这个问题?


下面是一些工作代码(不使用jQuery)与上面给出的不工作代码进行比较.

Javascript代码:

ajaxPort.send
(
   <server_url>,
   {
      valueTrue : true,
      valueFalse: false,
      valueNull : null
   }
);
Run Code Online (Sandbox Code Playgroud)

PHP代码:

var_dump(json_decode(file_get_contents('php://input'), true));
Run Code Online (Sandbox Code Playgroud)

服务器输出:

array(3) {
  ["valueTrue"]=>
  bool(true)
  ["valueFalse"]=>
  bool(false)
  ["valueNull"]=>
  NULL
}
Run Code Online (Sandbox Code Playgroud)

请注意,正确接收null,true和false值.

另请注意,在第二种方法中,$ …

ajax null jquery

16
推荐指数
3
解决办法
2万
查看次数

请解释奇怪的HTML表行跨行为

请考虑以下HTML表定义.

<table>
 <tbody>
  <tr>
   <td rowspan='2'>A</td>
   <td>2</td>
   <td rowspan='2'>B</td>
  </tr>
  <tr>
   <td rowspan='2'>C</td>
  </tr>
  <tr>
   <td>1</td>
   <td>3</td>
  </tr>
 </tbody>
</table>
Run Code Online (Sandbox Code Playgroud)

我希望桌子看起来像:

+---+---+---+
| A | 2 | B |
|   +---+   |
|   | C |   |
+---+   +---+
| 1 |   | 3 |
+---+---+---+
Run Code Online (Sandbox Code Playgroud)

但在Firefox,IE8和Chrome中,表格呈现如下:

+---+---+---+
| A | 2 | B |
+---+---+---+
| 1 | C | 3 |
+---+---+---+
Run Code Online (Sandbox Code Playgroud)

如果我向表中添加另一列,如下所示:

<table>
 <tbody>
  <tr>
   <td>a</td>
   <td rowspan='2'>A</td>
   <td>2</td>
   <td rowspan='2'>B</td>
  </tr>
  <tr>
   <td>b</td>
   <td rowspan='2'>C</td>
  </tr> …
Run Code Online (Sandbox Code Playgroud)

html html-table

4
推荐指数
1
解决办法
7470
查看次数

如何在 Windows 中的 powershell 中使用 ack 在文件中搜索“&lt;”?

我不知道如何转义“<”字符,而且我对“系统找不到指定的文件”错误感到困惑。任何人都可以帮忙吗?

我在 Windows XP 的 powershell 中使用 ack。

问题ack-grep: chars escaping与我的非常相似,但是为该问题提供和接受的解决方案对我不起作用。

PS C:\xampp\htdocs> ack abcd
<works as expected>
PS C:\xampp\htdocs> ack <
The redirection operator '<' is not supported yet.
At line:1 char:5
+ ack < <<<<
PS C:\xampp\htdocs> ack \<
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '\<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack [<]
The system cannot find …
Run Code Online (Sandbox Code Playgroud)

windows powershell escaping ack

3
推荐指数
1
解决办法
626
查看次数

标签 统计

ack ×1

ajax ×1

escaping ×1

html ×1

html-table ×1

jquery ×1

null ×1

powershell ×1

windows ×1