weixin_33736832 2013-09-10 09:33 采纳率: 0%
浏览 9

AJAX-检索多个数据

How can I use some data as global? For example:

$.ajax({
      type: 'GET',
      url: "php/setting.php",
      data: { name: name, lastname: lastname, firstname: firstname
      }
      dataType: 'html',
      context: document.body,
      async: false,
      success: function(data) {
        //how to get this name,lastname, and firstname
      }
});

How can I get this name, lastname, firstname, and use it as a global variable like:

 if(name == 'archie') {
 }

thanks.

  • 写回答

2条回答 默认 最新

  • weixin_33712987 2013-09-10 09:36
    关注

    I don't know if I fully understand the question but I think what you want to do is to set up an empty variable in your namespace (or in the global namespace if that's how you're doing it) such as var name; and then when you perform your AJAX request you want to do something like

    success: function(data) {
        name = data.name
      }
    
    评论

报告相同问题?

悬赏问题

  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?