为什么用jquery返回html标签

时间:2016-05-21 18:46:14

标签: javascript php jquery

为什么html标签会出现在我的输入框中以及我需要的变量。

<script>
    $(function() {
        $('a').click(function(event){ // use instead of onclick()
            event.preventDefault(); // prevents the default click action
            $.get('find_email.php', function(session) {
                 $('#id1').val( session); // session data will be 'foo'
            });
        });
    });
</script>
</head>

<body>
<a href="find_email.php">click</a>
<div><input id="id1" value=""></div>
</body>

php文件,find_email.php:

<?php
$var = $_SESSION['user_id']; 
echo $var;
?>

结果显示在输入框中:

<!DOCTYPE html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> 41

我想要的只是41出现在框中或分配给变量。

研究:

0 个答案:

没有答案