html get方法 - 两个单词的值问题

html get方法 - 两个单词的值问题

问题描述:

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

每个国家/地区名称作为一个单词的请求都会通过,只有“联合王国”不会。 p >

  $(“#content”)。load('view.php?country = united kingdom'); 
  code>  pre> 
 
 

非常感谢 p> div>

Try with encodeURI:

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

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" });