ShareThis

Wednesday, October 3, 2012

[PHP] Passing PHP parameters from a jQuery Load

I was running into a uncaught exception, error with expression when trying to pass php parameters in a jquery .Load("file.php?a= ... " );

This was occurring because the parameter value for "a" contained spaces.

You can get around this easily with this little hack:

$("#itemwithtext").text().split(" ").join("%20");

This will get the text of the given element, split it into an array delimiting with spaces, then join the array together using the %20 space command, which can be passed safely.

Related solutions

0 comments:

Post a Comment