HighDots Forums  

ajax

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


Discuss ajax in the Javascript (Italian) forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
chri
 
Posts: n/a

Default ajax - 04-29-2008 , 10:58 AM






Premetto che sono agli inizi con ajax. Ho provato ad eseguire una
chiamata XMLHTTPRequest e a visualizzare la risposta, ma senza successo!
In pratica vorrei realizzare un filtro dinamico su di un testo andando
ad interrogare il db lato server. Il risultato HTML non contiene perņ i
risultati php! Il codice di test č il seguente (nome del file "prova.php"):

<?
if (isset($_POST[action])){
$country = "Italia"; // di esempio quando premo un tasto su text city
//dovrebbe comparire "Italia" su test city1.
}
?>

<script type="text/javascript">
function GoH2H()
{
var obj;
if (window.XMLHttpRequest) {
obj = new XMLHttpRequest();
} else if (window.ActiveXObject) {
obj = new ActiveXObject("Microsoft.XMLHTTP");
}
try {
obj.open("POST", "prova.php", true);
obj.setRequestHeader('Content-Type',
'application/x-www-form-urlencoded');
obj.onreadystatechange = function(){
if (obj.readyState == 4) { // Caricamento Avvenuto
if (obj.status == 200) { // con successo

} else {
alert("Errore1: "+obj.statusText);
}
}
}
var item = document.getElementById('city');
var itemValue = item.getAttribute('value');
obj.send("action=1");
} catch (e) {
alert("Errore2: " + e);
}
}
</script>

<input type="text" name="city" id="city" onkeypress="GoH2H();"><input
type="text" name="city1" id="city1" value="<?=$country?>">

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

Default Re: ajax - 05-02-2008 , 04:26 AM






Quote:
Premetto che sono agli inizi con ajax
[cut]

allora ti consiglio qualche buona lettura come:
http://developer.mozilla.org/it/docs/AJAX


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 - 2008, Jelsoft Enterprises Ltd.