Skip to main content

Bug Tracker

Side navigation

#15087 closed bug (notabug)

Opened May 12, 2014 08:19PM UTC

Closed May 12, 2014 08:23PM UTC

Last modified May 12, 2014 08:30PM UTC

Space in URI making JQuery crash

Reported by: jorgee Owned by:
Priority: undecided Milestone: None
Component: ajax Version: 1.11.1
Keywords: ajax, url, white space, space Cc:
Blocked by: Blocking:
Description

If I have a space in the URI, like in the following example:

url = "/directory/buscador.php?q=[Nombre de Cliente|contiene|Gabriel|DESC]&p=1&v=lista"

function loadXMLDoc(url, div) {

$('#'+div).load(url);

// $('#'+div).load(url.replace(/ /g,'%20'));

}

Gives an error after the ajax call:

GET http://192.168.100.131/directory/buscador.php?q=[Nombre&_=1399925777172

200 OK

101ms

jquery-1.11.1.js (line 9631)

GET http://192.168.100.131/directory/buscador.php?q=[Nombre&_=1399925777173

200 OK

122ms

jquery-1.11.1.js (line 9631)

Error: Syntax error, unrecognized expression: de Cliente|contiene|Gabriel|DESC]&p=1&v=lista

throw new Error( "Syntax error, unrecognized expression: " + msg );

jquery-1.11.1.js (line 1473)

Attachments (0)
Change History (3)

Changed May 12, 2014 08:22PM UTC by jorgee comment:1

The function is

function loadXMLDoc(url, div) {

$('#'+div).load(url);

}

The $('#'+div).load(url.replace(/ /g,'%20')); is a workaround I made.

Changed May 12, 2014 08:23PM UTC by dmethvin comment:2

resolution: → notabug
status: newclosed

Please ask for help on StackOverflow or forum.jquery.com.

Changed May 12, 2014 08:30PM UTC by jorgee comment:3

Replying to [comment:2 dmethvin]:

Please ask for help on StackOverflow or forum.jquery.com.

You are right, because after space JQuery expects a selector. The bad thing is that there is no way to tell jquery that it is a full uri.