<script>
var er ="hi";
$( "#save" ).click(function() {
var er = $('#edit').val();
alert(er);
});
$.ajax({
type: 'POST',
url: 's.php',
data: { er:er},
success: function(response) {
alert(er);
}
});
</script>
从ajax发送数据到php
- 写回答
- 好问题 0 提建议
- 关注问题
- 邀请回答
-
1条回答 默认 最新
weixin_33743880 2014-09-30 07:46关注You must write the ajax code in click function, otherwise ajax code will execute on page load.
var er ="hi"; $( "#save" ).click(function() { var er = $('#edit').val(); alert(er); $.ajax({ type: 'POST', url: 's.php', data: {'er':er}, success: function(response) { alert(er); } }); });Try above code. it will work for you.
解决 无用评论 打赏 举报