我有一個名爲x的函數,這是一個插件的方法,但我使用可變像下面帕拉姆有問題:處理空間
var q= 'adele rolling in the deep';
x('http://search.azlyrics.com/search.php?q='+q); // doesn't worked
我做console.log('http://search.azlyrics.com/search.php?q='+q)
它給我 http://search.azlyrics.com/search.php?q=adele rolling in the deep
,爲什麼+
丟失?
當我與靜態URL來測試像下面它的工作
x('http://search.azlyrics.com/search.php?q=adele+rolling+in+the+deep'); // worked
'+ q' =>'+ encodeURIComponent(q)' – dandavis
@dandavis,把它作爲答案。 –
你想做什麼?用plus替換空格?或者讓空間與網址工作? –