user1996496 user1996496 - 2 months ago 7
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
href
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

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

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

}
Comments