On Jun 23, 4:31 pm, anawak82 <anawa...@googlemail.com> wrote:
> Hi Rob,
>
> thank you for your quick reply!
>
> > Add a return statement to getPrice, maybe something like:
>
> > function getPrice(id) {
> > return $.get('db.xml', function(d){
> > ...
> > });
>
> I am sorry to say that this only return a XMLHttpRequest but not the
> value of the variable price.
Your original function appears to be extremely inefficient, but
anyhow, without knowing the structure of the XML document you are
dealing with, use:
function getPrice(id) {
var price;
...
price = $data.find("preis").text().trim();
...
return price;
}
Note that price is declared in the outer function and not in the inner
function.
--
Rob