比方說,你有兩個按鈕。其ID號:如何在PHP請求處理空間
bob
bobs burgers
您使用jquery的div元素來.load一個PHP頁面類似如下:
var teamSelect = $(this).attr('id');
$("#loadTables").load("php/leagueTable.php?team="+teamSelect);
現在Bob將運行得很好,但開心漢堡店有一個空間,不工作。地址結束爲
"php/leagueTable.php?team=bobs"
我無法控制的事實,將在按鈕Ids中有空格。這些按鈕是從數據庫生成的,這些名稱將始終有空格。我該如何處理這個問題?
編碼uricomponent應該工作。 請參閱[http://stackoverflow.com/questions/6544564/url-encode-a-string-in-jquery-for-an-ajax-request][1] [1 ]:http://stackoverflow.com/questions/6544564/url-encode-a-string-in-jquery-for-an-ajax-request –