function ajaxFunction(){
var ajaxRequest; // The variable that makes Ajax possible!
try{
// Opera 8.0+, Firefox, Safari
ajaxRequest = new XMLHttpRequest();
} catch (e){
// Internet Explorer Browsers
try{
ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try{
ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e){
// Something went wrong
alert("Your browser is too old to run me!");
return false;
}
}
}
// Create a function that will receive data sent from the server
ajaxRequest.onreadystatechange = function(){
if(ajaxRequest.readyState == 4){
$.post('userfind.php', function(data) {
$("#resultTXT").val(data);
var response = data;
var parsedJSON = eval('('+response+')');
alert('parsedJSON:'+parsedJSON);
var result=parsedJSON.result;
var count=parsedJSON.count;
alert('result:'+result+' count:'+count);
},'json'
); }
}
ajaxRequest.open("POST", "userfind.php", true);
ajaxRequest.send(null);
}
块引用 所以我得到了上面的代码,你们的帮助。上面的代码将用字符串填充txtbox,但我无法访问字符串的每个元素。该字符串是使用Jsone_encode从PHP文件分页的数组。
数组是这样的。 [{"user_id":"2790","freelancer_name":"","order_id":"9121","orderamount":"0.00"
我想做的是编写这样的代码:
document.getElementById("_proId").value = user_id;
document.getElementById("_buyerSt").value = freelancer_name;
document.getElementById("_buyerDesc").value = order_id;
document.getElementById("_mngSt").value = orderamount;
... etc
块引用 所以我的问题是如何拆分字符串并获取数据。这两个变种
var result=parsedJSON.result;
var count=parsedJSON.count;
alert (""+result);
alert (""+count);
只提醒我未定义。
请帮我从字符串中获取数据。
从mysql表中获取数组并且它很大