user1996496 user1996496 - 4 months ago 14
jQuery Question

How do I replace an attribute in a function with a variable?

I have this code:

.load($(this).attr('href'), function (responseText, textStatus) {

Now, I want to modify that to loading a predefined variable instead of the
attribute. I tried this here but get an error:

params="option=1"; // example
var URL=ajax_url+"/?"+params;

.load($(this)URL, function (responseText, textStatus) {

What's the correct way?


If your "URL" is valid, then it should just be:

.load(URL, function (responseText, textStatus) {