user1996496 user1996496 - 1 year ago 64
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?

Answer Source

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

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

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