传递价值包括空间上的Ajax调用 [英] Passing Value Including Spaces on Ajax Call

查看:115
本文介绍了传递价值包括空间上的Ajax调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图通过空间与AJAX调用。

Trying to pass spaces along with ajax call.

字是已通过相同的字我想是的。

'word' is been passed the same as 'word ' i believe so.

另外两个词需要与电话完全发送。

On the other hand two words need to be send completely with call.

字第二,但不一样的 '字第二个

'word second' but not the same as 'word second '

电话之前我应该​​修剪或做这在服务器端脚本? 我如何发送的空间呢?

Should I trim before call or do this on server side script? How can I send spaces as well?

推荐答案

要允许参数包含空格,等你将要使用的JavaScript 越狱() [ W3Schools的]功能。

To allow a parameter to include spaces, etc. you will want to use the javascript escape() [W3Schools] function.

escape( 'hello world ' ) = 'hello%20world%20';

具体的处理在PHP端会自动德code /反向转义的参数,恢复空间(连同任何其它的字符时,通过AJAX的发送,这不可能是一个参数的值的一部分,例如=或 &功放;

The handling on the PHP side will automatically decode/unescape the parameter, restoring the spaces (along with any other characters which cannot be part of a parameter's value when sent through AJAX, such as "=" or "&".

在PHP中,如果你是想去掉开头和结尾空格,你可以使用PHP 修剪() [ PHP.net ]功能。

Within PHP, if you are wanting to strip off any leading or trailing spaces, you can use the PHP trim() [PHP.net] function.

trim( 'hello world ' ) = 'hello world';

这篇关于传递价值包括空间上的Ajax调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆