-2
Code:Uncaught Typeerror: request.open ist keine Funktion
// urlget.html
<!DOCTYPE html>
<html>
<head>
<title>AJAX GET-request example</title>
</head>
<body style='text-align:center'>
<h1>Loading Web page into DIV</h1>
<div id='info'>This sentense will be replaced</div>
<script>
nocache = "&nocache=" + Math.random() * 1000000
request = new ajaxRequest()
request.open("GET", "urlget.php?url= amazon.com/gp/aw " + nocache, true)
request.onreadystatechange = function()
{
if (this.readyState == 4)
{
if (this.status == 200)
{
if (this.responseText != null)
{
document.getElementById('info').innerHTML = this.responseText
}
else alert('AJAX error: Data not received')
}
else alert("AJAX error: " + this.statusText)
}
}
request.send(null)
function ajaxRequest()
{
try
{
request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch(e2)
{
try
{
request = new ActivateXObject("Microsoft.XMLHTTP")
}
catch(e3)
{
request = false
}
}
}
function ret(request){return request}
ret(request)
</script>
</body>
</html>
ich diesen Fehler:
Uncaught TypeError: request.open is not a function
'ajaxRequest' gibt nichts zurück. Warum benutzt du überhaupt "neu"? Versuchen Sie, "request" global innerhalb der Funktion zu ändern? – Xufox