我有这个以下错误,我不明白为什么没有什么显示在我的“div”。 我想在我的div“mycontent”的名为ticket.php的新页面中显示我的票的内容。ajax请求传递变量到另一个页面
的script.js:
function displaytickets(){
var newid = {};
$("#mylist").empty();
$("#nbtick").html("");
$("#mycontent").html("");
var y = document.getElementById("mySecond").value;
$.ajax({
url: "https://cubber.zendesk.com/api/v2/users/"+y+"/tickets/requested.json",
type: 'GET',
dataType: 'json',
cors: true ,
contentType:'application/json',
secure: true,
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(""));
},
success: function (data){
for (i = 0; i < data.tickets.length; i++) {
var mytitle = data.tickets[i].subject;
var description = data.tickets[i].description;
var status = data.tickets[i].status;
var myid = data.tickets[i].id;
console.log(data.tickets[i]);
var created = data.tickets[i].created_at;
var nbticket = data.tickets.length;
$("#mylist").append('
'+ mytitle +" #"+ myid+ "---"+status +"---"+created+'')}
$("#nbtick").append('
'+nbticket+'
');},
});
$("#idisplay").css("display", "none");
}
function ticketcontent (newid){
window.location = "http://localhost:8888/support-cubber/ticket.php";
// var newid = {};
// var newid = document.getElementById("newlist").value;
console.log(newid);
$.ajax({
url: "https://cubber.zendesk.com/api/v2/tickets/"+newid+"/comments.json",
type: 'GET',
cors: true,
dataType: 'json',
contentType:'application/json',
secure: true,
beforeSend: function (xhr) {
xhr.setRequestHeader ("Authorization", "Basic " + btoa(""));
},
success: function (data){
for (var i = 0; i < data.comments.length; i++) {
var alldata = data.comments[i].body
$("#mycontent").append('
'+alldata+'
');console.log(alldata);
}
},
});
var newid = {};
}
ticket.php:
Support CubberHello world !
2016-03-31
xenurs
+0
您需要在ticket.php页面中使用window.location导航到您的ajax函数。 –
+0
#psyLogic我不能将我的功能移动到其他页面,因为即时通讯使用我的请求中的变量链接到以前的请求(我重新编辑我的帖子来显示你) –
+0
你没有别的选择,你可以发送该变量作为URL参数或将其存储在Cookie中并在其他页面中访问它。 –