Javascript CasperJS don';我不能提出我的AJAX请求

Javascript CasperJS don';我不能提出我的AJAX请求,javascript,phantomjs,casperjs,Javascript,Phantomjs,Casperjs,我对CasperJS有点反感。我试图单击onclick上有AJAX请求的链接。AJAX请求从未发出过 以下是我的index.php页面: <html> <head> <title>AJAX test</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js> </script> &

我对CasperJS有点反感。我试图单击onclick上有AJAX请求的链接。AJAX请求从未发出过

以下是我的index.php页面:

<html>
<head>
    <title>AJAX test</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js>
    </script>
    <script>
    function test(id){
        $.ajax({
            type: 'POST',
                data: {
                    'id': id
                },
                url: 'test.php',
                async: false
        });
        alert('OK');
        return true;
    }
</script>
</head>
<body>
    <a onclick="return test(1)" href="http://www.google.fr">www.google.fr</a>
</body>
</html>
<?php 

print_r($_POST['id']);
mail('mymail', 'Test AJAX', $_SERVER['REMOTE_ADDR'].' : '.$_POST['id']);

?>

“警报”消息启动良好,但AJAX请求没有启动。你知道为什么吗?好的,我找到答案了。问题是因为我使用的代理需要身份验证,而AJAX请求没有发送所需的用户和密码

我直接将代理配置为允许来自我的IP的所有连接,而无需身份验证,并且它可以工作

var utils = require('utils');
var casper = require('casper').create({
verbose: true,
logLevel: "debug"
});

casper.start('http://www.example.com/index.php');

casper.thenEvaluate(function(term) {}, 'CasperJS');

casper.then(function() {
    this.click('a');
});

casper.then(function() {
    console.log('clicked ok, new location is ' + this.getCurrentUrl());
});

casper.run();