tronghiep92 0 Newbie Poster

I problem AJAX jquery. How block run AJAX from console.log

EX test on localhost:
file index.html:

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script>
$(document).ready(function(){
    var btn = $('button');
    btn.on('click', function(){
        $.ajax({
            url : 'process.php',
            type : 'post',
            data : {id : 1},
            success: function(data){
                console.log(data);
            }
        });
    });
});
</script>
</head>
<body>
    <button>CLick</button>
</body>

file process.php:

<?php
if(isset($_POST['id'], $_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], 'localhost')!==false ){
    echo $_SERVER['HTTP_REFERER'];
}else{
    echo 'No';
}

Run console show imgae
Click Here
tks!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.