ajax传送变量怎么写代码,ajax请求传递变量到另一个页面

我有这个以下错误,我不明白为什么没有什么显示在我的“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 Cubber

Hello world !

2016-03-31

xenurs

+0

您需要在ticket.php页面中使用window.location导航到您的ajax函数。 –

+0

#psyLogic我不能将我的功能移动到其他页面,因为即时通讯使用我的请求中的变量链接到以前的请求(我重新编辑我的帖子来显示你) –

+0

你没有别的选择,你可以发送该变量作为URL参数或将其存储在Cookie中并在其他页面中访问它。 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值