user6813858 user6813858 - 1 year ago 84
Ajax Question

How to appending url path in jquery


in jQuery Ajax
field gives the URL path but when i use a prefix in front of it like this:

type: 'GET'
url: 'api/'+ $(this).attr("href");

it doesn't work.

Whats going wrong? Is this wrong method or is there a better way?

Answer Source

$(this) -> will return a wrong result in the object.

Get the value in another place and add the ready result;

var getURL = 'api/'+ $(this).attr("href"); // In the level,where your $(this) is the actual this

    type: 'GET',
    url: getURL
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download