开发者

html get method - two words value issue

开发者_JS百科every request with country name as an one word goes through, only "united kingdom" doesn't.

$("#content").load('view.php?country=united kingdom');

many thanks


Escape United Kingdom using encodeURIComponent, mainly to replace the space with a plus sign.

Example:

country = "united kingdom";
$("#content").load('view.php?country=' + encodeURIComponent(country));

Alternatively, use the .load data parameter, which is automatically escaped.

$("#content").load('view.php', { country: "united kingdom" });


Try with encodeURI:

$("#content").load(encodeURI('view.php?country=united kingdom'));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜