JQuery - Do I need a URL to encode a variable?

I am using ColdFusion 9 and the latest and greatest jQuery.

At the top of my page, I use the following:

<cfajaxproxy cfc="artists" jsclassname="jsApp">

I have a search box:

<input id="Artist" class="Search" type="text">

When the user enters the search field, the value is passed to the jQuery function:

$(".Search").keyup(function() {
  var Artist = $("#Artist").val();
  var QString = "Artist=" + Artist;
  $("#ArtistSearchResultsDiv").load("ArtistSearchResults.cfm?"+QString);
});

Div search results load a page with these elements in CFSCRIPT:

objArtists = createObject("component", "artists");
GetArtists = objArtists.getArtists(Artist);

I have a CFC that starts a query and returns the correct records.

The PROBLEM is that when I enter a search field, as soon as I find a space, no additional value is added to the QString variable, and therefore these values ​​are not passed to the request.

Here's what the search string in Firebug looks like when searching for "The Beatles":

GET http://127.0.0.1:8500/WebSites/AwesomeAlbums/GlobalAdmin/ArtistSearchResults.cfm?Artist=The

He stops as soon as he sees a gap.

, "The Beatles", "The" QString. " ", "".

, - QString. ? ?

+5
1
var QString = "Artist=" + encodeURIComponent(Artist);
+9

All Articles