Javascript 为什么jquery会返回html标记
为什么html标记与我需要的变量一起出现在我的输入框中Javascript 为什么jquery会返回html标记,javascript,php,jquery,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(sess
<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>
$(函数(){
$('a')。单击(函数(事件){//使用而不是onclick()
event.preventDefault();//阻止默认的单击操作
$.get('find_email.php',函数(会话){
$('#id1').val(会话);//会话数据将为'foo'
});
});
});
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
我想要的只是框中出现的41或分配给变量
研究: