I'm implementing Google's Instant Search in my application.(我正在我的应用程序中实现Google的即时搜索。)
I'd like to fire off HTTP requests as the user types in the text input.(我想在用户输入文本输入时触发HTTP请求。) The only problem I'm having is that when the user gets to a space in between first and last names, the space is not encoded as a +
, thus breaking the search.(我唯一遇到的问题是,当用户到达名字和姓氏之间的空格时,该空格未编码为+
,从而破坏了搜索。) How can I either replace the space with a +
, or just safely URL Encode the string?(如何用+
代替空格,或者仅安全地对字符串进行URL编码?)
$("#search").keypress(function(){
var query = "{% url accounts.views.instasearch %}?q=" + $('#tags').val();
var options = {};
$("#results").html(ajax_load).load(query);
});
ask by Brian D translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…