您好我正在开发一个chrome应用程序并在amazon elasticbeanstalk中托管了几个文件,并通过ajax向该php文件发送请求。这是我的 ajax 代码
var dataString = "em=" + email + "&ids=" + ids + "&retrieve";
$.ajax({
type: "POST",
url: "http://xxxxx.elasticbeanstalk.com/retrieve_item.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {},
success: function(data1) {
var ss = jQuery.parseJSON(data1);
$.ajax({
type: "POST",
url: "http://xxxxx.elasticbeanstalk.com/retrieve_stock.php",
data: dataString,
crossDomain: true,
cache: false,
beforeSend: function() {},
success: function(datas) {
if (ss.length == 0) {
var sts = "TICKET ID : " + 1;
$(".payticket").text(sts);
} else {
var ss1 = jQuery.parseJSON(
datas);
for (var s = 0; s < ss.length; s++) {
var dt = ss[s].ticket_date;
var dt1 = dt.split("-");
console.log(dt1);
var d_day = parseInt(dt1[2]);
if (d_day < 10) {
d_day = "0" + d_day;
}
var d_month = dt1[1];
var d_year = dt1[0];
var ddate = d_year + "-" +
d_month + "-" + d_day;
console.log(ddate);
var todays_date =
currentDate.split("/");
var t_year = todays_date[2];
var t_mnt = todays_date[1];
var t_day = parseInt(
todays_date[0]);
if (t_day < 10) {
t_day = "0" + t_day;
}
var tdate = t_year + "-" +
t_mnt + "-" + t_day;
console.log(tdate);
var gid = ss[s].id;
var gids = ss[0].id;
var gg = parseInt(gids) + 1;
var gg1 = "TICKET ID : " +
gg;
$(".payticket").text(gg1);
if (ddate == tdate) {
var stat = ss[s].ticket_status;
var cn = ss[s].client_name;
var tot = ss1[s].final_total;
var tstat;
var cls;
if (stat == "open") {
tstat = "OPEN";
cls = "open";
} else {
tstat = "CLOSED"
cls = "open1";
}
$("#cashreg1").append(
'<tr id="' +
gid +
'"><td><div class="backshadow"><div class="cells1"><div class="titlebar"><label class="ticket">TICKET ID - ' +
gid +
'</label><label class=' +
cls + '>' +
tstat +
'</label></div><input type="checkbox" class="check_condition" style="display:none;"><div class="whitecontent"><label class="name">' +
cn +
'</label><label class="close">' +
tot +
'</label></div></div></div></td></tr>'
);
}
}
}
}
});
}
});
首先ajax响应数据,但外部ajax成功的另一个ajax调用无法响应。 ajax有什么问题吗?我删除了dataType =&#39; json&#39;并尝试添加它,但我没有得到任何回应。 这是我的 php 代码
$em=$_POST['email'];
$sid=$_POST['ids'];
$data=array();
$q1="SELECT * FROM `".$em."`.`".$em."_".$sid."_single_item`";
$q = mysqli_query($sql,$q1);
while ($row=mysqli_fetch_object($q)){
$data[]=$row;
}
echo json_encode($data);
我返回json数据。上面的代码有什么问题吗?有人可以帮助我吗?