Php jquery post和响应操作
我有一个类似jquery的帖子Php jquery post和响应操作,php,javascript,jquery,post,Php,Javascript,Jquery,Post,我有一个类似jquery的帖子 <script type = "text/javascript" > $(document).ready(function() { $('#find').click(function() { var amount = $('#amount').val(); $.ajax({ type: "POST", contentType: "application/x-www-
<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>
Array ( [0] => mpla mpla [1] => mplum mplum ....
在屏幕上显示之前,如何使用jquery或javascript获取项目
我只想像链接的文本
mpla mpla -->that is a link
mplum mplum -->that is a link too
首先,您需要将其转换为json格式 然后您可以使用
$访问它们。每个循环
$.each(data , function(i , value){
console.log( 'Index - ' + i + ' = ' + value );
});
首先,您需要将其转换为json格式
然后您可以使用$访问它们。每个循环
$.each(data , function(i , value){
console.log( 'Index - ' + i + ' = ' + value );
});
在php中。做一个:
echo json_encode( YOUR ARRAY );
将jQuery$.ajax设置数据类型设置为json
在成功函数中,您现在可以使用
success : function(data){
// data is now a javascript array
var st = data.join(" ");
}
在php中。做一个:
echo json_encode( YOUR ARRAY );
将jQuery$.ajax设置数据类型设置为json
在成功函数中,您现在可以使用
success : function(data){
// data is now a javascript array
var st = data.join(" ");
}
那真是又快又好!谢谢!那真是又快又好!谢谢!