Have you ever come upon this annoying error message: “undetermined string literal”.
Ok, i’ve got 3 occasions were you might run into this error and how to fix it for each specific case.
- Multiple Line Strings
- Wrong String Format (Bad Characters)
- Angle Brackets
Multiple Line Strings
Another way is to simply split your string up into bits and add them together.
Wrong String Format (Bad Characters)
If your trying to assign HTML to a variable you might see the “Undetermined String Literal” error. It might be that you loaded the HTML from somewhere else via ajax and are now trying to use/inspect it. Use the following code to clean up the bad characters in the string before trying to assign it.
If your trying to use angle brackets (“>” & “<") within a string you might see the "Undetermined String Literal" error when trying to submit the string data via ajax.
//note: abc replaces the actual query
It turns out it was the securequery angle brackets creating the error and I had to hack it (as such) by adding in the angle brackets (“<" & ">“) just before encoding and sending the request via AJAX (see below).
data: 'content=' + encodeURIComponent('<'+contentQuery+'>'),
This might even be a bug in jQuery, not sure though. When you test in firebug it works though! So maybe not…