HighDots Forums  

Callback - Problema di scoping

Javascript (Italian) Il linguaggio JavaScript (it.comp.lang.javascript)


Discuss Callback - Problema di scoping in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
inmodis@tiscalinet.it
 
Posts: n/a

Default Callback - Problema di scoping - 12-19-2008 , 10:11 AM






Ciao,

devo avere un po' di confusione in testa. Il mio scopo è - usando
jquery che pure conosco pochino - prelevare un documento XML e
memorizzare per accesso differito il relativo dom

Guardate questo codice:

---------------------------------------------------------------------------------------------

var globDom; // The DOM object

// Prelevo il file xml di cui il metodo jquery fa il parsing
// saveXML è la callback

$.get(requestTarget, {}, saveXML);

// qui la variabile globDom risulta UNDEFINED

alert(globDom);

function saveXML(xmlDom)
{
globDom = xmlDom;
}

---------------------------------------------------------------------------------------------

di fatto non riesco a rendere visibile globalmente il risultato del
parsing effettuato implicaitamente. Di fatto il problema non è il
parsinig, ovvero qualunque valore messo nella variabile risulta
illeggibile

Qualcuno sa darmi un suggerimento?

Ciao

Daniele

Reply With Quote
  #2  
Old   
Oreste
 
Posts: n/a

Default Re: Callback - Problema di scoping - 12-19-2008 , 11:49 AM






On Dec 19, 6:11*pm, inmo... (AT) tiscalinet (DOT) it wrote:
Quote:
$.get(requestTarget, {}, saveXML);
a prima vista saveXML non viene interpretato come funzione, il codice
che hai postato non è completo.

Comunque potresti agevolmente usare il seguente:

$.get(requestTarget, function(data) {
alert(data);
});


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.