ボタンをクリックするだけでAJAXリクエストを起動したいのですが、バックエンドでトリガーできません。
index.php:
<html>
<head>
<script type="text/javascript">
var req = new XMLHttpRequest();
function send1()
{
req.open("GET", "process.php?q=hello", true);
req.send();
alert(req.responseText);
}
</script>
</head>
<button onclick=send1()>send</button>
</html>
process.php:
<?php
$new= $_GET['q'];
echo $new;
?>
これにより、アラートボックスに「こんにちは」と表示されるはずです。なぜそうではないのですか?