Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/grails/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 单击';a';元素,我的脚本未捕获转换_Php_Jquery - Fatal编程技术网

Php 单击';a';元素,我的脚本未捕获转换

Php 单击';a';元素,我的脚本未捕获转换,php,jquery,Php,Jquery,在我的网站的每个页面中,我都包含javascript代码,它是: $(document).ready(function () { $("a").click(function () { var adress = $(this).attr("href"); $.post("changeURL.php", { send: adress }); }); }); 当用户单击页面中的每个链接时,我想捕捉到到到另一个页面

在我的网站的每个页面中,我都包含javascript代码,它是:

$(document).ready(function () {
    $("a").click(function () {
        var adress = $(this).attr("href");
        $.post("changeURL.php", {
            send: adress
        });
    });
});
当用户单击页面中的每个链接时,我想捕捉到到到另一个页面的转换。并重定向到某个页面,参数为点击地址。例如:

<?php
   if(isset($_POST['send'])){
     $site_name = $_POST['send']."?from=mysite.localhost";
     header("parser.php/?parsingThisSite=".$site_name);
     exit();    
   }
?>
我做错了什么?为什么单击后它没有转到“changeURL.php”,而是直接转到href属性中的链接。

备注:我的Web服务器是USBWebServer,jQuery版本是1.10.2

它是否打算删除某些内容?此代码将把您的链接地址发送到服务器,如果您打算阻止重定向,请在单击锚点时在单击事件结束时添加以下内容之一

$('a').click(function() {
   // your code
   return false;
});


您正在尝试删除某些内容,还是重定向用户?有什么提醒吗?检查控制台,上面写着什么?还有人否决了你,可能是因为你的问题不是问题。您可能想编辑一下您的帖子。为什么不使用
$.post的
done
回调?
<?php
   if(isset($_POST['send'])){
     echo "<script>alert('hello')</script>";  
   }
?>
$(document).ready(function () {
    $("a").click(function () {
        alert("You want to go!");
    });
});
$('a').click(function() {
   // your code
   return false;
});
$('a').click(function(event) {
   // your code
   event.preventDefault();
});