Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass query parameter as string into jquery load that includes space

Hi i have a simple question. I want to know how to pass a query string into a query parameter using jquery.

function loadPage(queryString) {
    jQuery("#divId").load("myurl/action?param=" + queryString);
}

queryString could be like "1,2,3,4" or "testing 1 2 3".

When I tried it only the first parameter is their. I want to be able to pass in a sentence, or a paragraph.

like image 399
Chun ping Wang Avatar asked Feb 07 '13 17:02

Chun ping Wang


1 Answers

try

function loadPage(queryString) {
    jQuery("#divId").load("myurl/action?param=" + encodeURIComponent(queryString));
}
like image 87
marty Avatar answered Sep 22 '22 09:09

marty