使用ajax post时如何将返回数据放入php变量中

时间:2015-12-17 05:50:35

标签: php ajax post

我目前正在使用ajax帖子从其他页面检索数据。为了在将来重用返回的值,我想将它分配给php变量。有可能吗?

success: function(data) {
 $('#display').html(data);
}

2 个答案:

答案 0 :(得分:1)

你不能。 php文件首先在服务器中完成它的执行,结果传递给浏览器。然后在浏览器中执行javascript(即ajax)部分。阅读答案here了解更多信息。

答案 1 :(得分:0)

你可以使用:

<script type="text/javascript">
var jvalue = 'this is javascript value';

<?php $abc = "<script>document.write(jvalue)</script>"?>   
</script>