
Originariamente inviata da
cavicchiandrea
Vediamo anche la chiamata onload....
Si scusa, praticamente passo alla funzione 2 parametri:
codice HTML:
<body onLoad="ajaxRequest(<?php print $_GET["id"];?>, 'jobs_of_sow.php?id=')">
questa è la parte js che viene inclusa:
codice:
function xmlhttp()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
//Simbolo di attesa
var caricamento="<img src='../../image/loading.gif' height='40px'>"
document.getElementById("myDiv").innerHTML=caricamento;
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
setTimeout(
function()
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
,2000
);
}
}
return xmlhttp;
}
function ajaxRequest(value, file)
{
xmlhttp = xmlhttp();
var PHPpage = file + value;
if(value != '')
{
xmlhttp.open("GET", PHPpage, true);
xmlhttp.send();
}
}
Quindi poi nel button richiamo la stessa funzione :
codice:
<button onclick="ajaxRequest('', 'elimina.php');">
ma non da segni di vita a differenza di quando faccio l' onload che funziona alla perfezione. Grazie Andrea