Jquery gives a Syntax error, unrecognized expression on calling a url including “(”

i am facing an error in Jquery Load function. I am using jquery to find a string in MySQL database table. here is a sample of my code.


here, i am using "code" as input. when i use "(" in code like:

code = "DQ118 (dq10)";

browser gives me an error like:

Uncaught Syntax error, unrecognized expression:  (


It works pretty fine, look here. Just maybe try to encode your URI, by using encodeURIComponent

code = "DQ118 (dq10)";

and use var before you declare your variable. For example

var code = "DQ118 (dq10)";
var nUrl='count.php?coun='+encodeURIComponent(code);

so you avoid declaring your variable globally

First of all you must declare the variables ( var code = 'blah'; )

also, "escape" the string:

var code = escape("DQ118 (dq10)");
var nUrl = 'count.php?coun='+code;

I've tried it and i don't get that error. In any case you should use encodeURIComponent i think on the code variable

code = encodeURIComponent("DQ118 (dq10)");

follow this previous question on this site Escaping HTML strings with jQuery

it is much clear to understand and help to solve further problems like this..

it works somewhat like this:

html.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");

Need Your Help

How to implement a “horizontal toggle responsive menu, where excess menuitems are combined into a dropdown”?

jquery design-patterns user-interface menu responsive-design

I'm trying to find some lead/information/implementation on a top toggle menu for a website that selectively and progressively moves low-priority menuitems into a submenu (eg. "more...") as it tries...

Unwrap XPCNativeWrapper object in Firefox versions < 3.6.2

javascript firefox-addon wrapper

Is there a way to unwrap an XPCNativeWrapper object in early versions of Firefox (before version 3.6.2)?

Simple Scala getter/setter override

scala inheritance properties setter getter

Let's say we have a class with a 'name' property:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.