我有一篇类似的 jquery 帖子
<script type = "text/javascript" >
$(document).ready(function() {
$('#find').click(function() {
var amount = $('#amount').val();
$.ajax({
type: "POST",
contentType: "application/x-www-form-urlencoded;charset=utf-8",
url: "questions.php",
data: {
'amount': amount
},
success: function(data) {
$('#results').show();
$('#results').html(data);
}
});
});
});
</script>
成功的数据有一个像这样的 php 数组
Array ( [0] => mpla mpla [1] => mplum mplum ....
如何在屏幕上呈现项目之前使用 jquery 或 javascript 获取项目。
我只想要像链接一样的文本
mpla mpla -->that is a link
mplum mplum -->that is a link too
最佳答案
在你的 php.ini 中做一个:
echo json_encode( YOUR ARRAY );
将 jQuery $.ajax 设置数据类型设置为 json。
在您的成功函数中,您现在可以使用
success : function(data){
// data is now a javascript array
var st = data.join(" ");
}
关于php - jquery 发布和响应操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12900940/