开发者

html get method - two words value issue

开发者 https://www.devze.com 2023-02-21 19:16 出处:网络
开发者_JS百科every request with country name as an one word goes through, only \"united kingdom\" doesn\'t.

开发者_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

精彩评论

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