Bug Tracker

Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#15087 closed bug (notabug)

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)

Change History (3)

comment:1 Changed 5 years ago by jorgee

The function is

function loadXMLDoc(url, div) {

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

}

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

comment:2 Changed 5 years ago by dmethvin

Resolution: notabug
Status: newclosed

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

comment:3 in reply to:  2 Changed 5 years ago by jorgee

Replying to 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.

Note: See TracTickets for help on using tickets.