ajax 转换成字符串,将JSON字符串(通过ajax发送)转换为pythonlis

我有一个数组,它使用JSON.stringify这样我就可以通过ajax将数据发送给Python处理程序。这使我可以将数据保存为一个刺…括号,引号,等等。我需要这些数据在某种可用的列表或数组中…而不仅仅是字符串。谢谢你的鼓励,谢谢。在

保存在数据库中的字符串格式(数据存储-使用GAE):

[“上午15点”,“下午3点”,“下午4点”,“下午4点”,“下午3点”]

javascript/ajax代码:var ids = new Array();

$('.ui-selected').each(function(){

ids.push($(this).attr('value')); //adds items selected to the array so that they can be passed via ajax

console.log('**item added to data object**');

});

string_ids = JSON.stringify(ids, null); //converts array object to a string to pass via ajax

$.ajax({

type: "POST",

url: '/schedule',

data: {'ids': string_ids}, //string of selected items

});

Python处理程序:

^{pr2}$

Python模型:class AvailableTimes(db.Model):

user = db.StringProperty()

timezone = db.StringProperty()

ids = db.StringProperty()

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值