|
[x]
Posted via EE Mobile
|
|
| Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
|
|
|
|
Asked by solohayuno in Asynchronous Javascript and XML (AJAX), HTMLkit
need to pass a variable to hello.php script
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
|
<!--Ajax file-->
<script language="JavaScript">
function createInstance()
{
var req = null;
if (window.XMLHttpRequest)
{
req = new XMLHttpRequest();
}
else if (window.ActiveXObject)
{
try {
req = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e)
{
try {
req = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e)
{
alert("XHR not created");
}
}
}
return req;
};
function storing(data, element)
{
element.innerHTML = data;
}
function submitForm(element)
{
var req = createInstance();
req.onreadystatechange = function()
{
if(req.readyState == 4)
{
if(req.status == 200)
{
storing(req.responseText, element);
}
else
{
alert("Error: returned status code " + req.status + " " + req.statusText);
}
}
};
req.open("GET", "hello.php", true);
req.send(null);
}
</script>
</head>
<body>
<FORM name='ajax' method='POST' action=''><INPUT type='button' value='Summit' ONCLICK='submitForm(document.getElementById("storage"))'></FORM>
</html>
//php script on another file
<?php
$Computer= $_POST['Data'];
`echo "$Computer"`
?>
|
20091111-EE-VQP-92 - Hierarchy / EE_QW_3_20080625