开发者

jQuery - passing querystring values to $(selector).load(url); not working

I have the following lines of code:

var search = $("#txtSearch").val();
search.replace(" ", "%20");
$(".header").html("/Parts/Search.php?type=" + $("input[name=type]:checked").val() + "&q=" + search);
$(".main-content").load("/Parts/Search.php?type=" + $("input[name=type]:checked").val() + "&q=" + search);

I know there is a textbox with the id specified in the first line, and two inputs of type radio with the name set to type. The value passed for type is either postcode or normal. The correct output (as far as I can see) is being displayed in a开发者_如何学Gony elements satisfying the .header selector. However the page is not loading into .main-content. There is another page, called Search.php, to which the user is taken if JS is disabled (i.e. there is a submit button which submits to /Search.php through the GET method - this disappears and a Search link appears if JS is enabled). If this page has the two querystring parameters specified then it will include /Parts/Search.php. This works fine - it reads the querystring from the parent (root level) Search.php. I dont get why it wont work with jQuery though. Does anyone have any ideas?

Thanks in advance,

Richard

PS I have also tried attaching the value of the search box on the end of the URL, without storing it in a variable and then replacing the space... this didnt work either.


Line 2 looks suspicious to me. replace returns a value. Try this.

search = search.replace(" ", "%20");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜