I have the following function:
var id = "10";
var type = "Type A";
var img = "myimage.jpg";
jQuery.post("my/path/somefile.php", { instance: 'getUrl', ID : id, type: type},
function(data)
{
jQuery('#logo').attr("src",data.url + img);
},"json");
- How can I get the value of
img
when I'm inside the function? - How can I sett
img = new value
from inside the function?
UPDATE
This code does NOT give a new value to the variable:
logoUrl = "noLogo.png";
jQuery.post("my/path/somefile.php", { instance: 'getUrl', ownerID : "123", type: "brand"},
function(logo)
{
logoUrl = logo.url + "logo/";
},"json");
alert(logoUrl); // This outputs noLogo.png"