thor thor - 1 year ago 145
jQuery Question

jquery load URL Syntax error, unrecognized expression

Can't work out what's wrong with this code, this is the code for the URL but it's throwing a sytax error: unrecognized expression.


$("a.qshop-btn").on('click', function () {

var $target = $(this).data('target');

var q = $(this).data('name');

var url = $('http://localhost/html/quickShop.php?q='+encodeURIComponent(q));

$("#qs-content").load(url, function (response,status,data) {


$($target).modal({ show:true });


obe obe
Answer Source

You are trying to make the url into a JQuery object whereas it's a simple string. Just write it like this: var url = 'http://localhost/html/quickShop.php?q='+encodeURIComponent(q);

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download