weixin_33734785 2016-04-30 10:18 采纳率: 0%
浏览 66

Ajax返回值到url

The main purpose is to get the data changed in excel and return the data to certain URL,so I can update data into database.

I've got the value of changed data,the changed data is an array.

How do I pass them to response and return to URL?

Here is the code:

afterChange: function(source, changes) {
    var a;
    if (changes !== 'loadData') {
        $.ajax({
            async: false,
            url: 'url.com',
            dataType: 'json',
            success: function(res) {
                //get data changed at row
                a = hot.getDataAtRow(source[0][0]);
                res = a;
                //console shows the value of res was changed to a;
                console.log(res);
            }
        });
        return a;
    }
}
  • 写回答

1条回答 默认 最新

  • DragonWar% 2016-04-30 14:19
    关注

    I thought you need to make some modification in your code if you want to post data on server after converting it. First you convert it then send it to server.

    afterChange: function(source, changes) {
        var a;
        if (changes !== 'loadData') {
            a = hot.getDataAtRow(source[0][0]);
            postDataToServer(a);
        }
    }
    
    function postDataToServer(a){
    $.ajax({
                async: false,
                url: 'url.com',
                data: a,// JSON.stringify(a), if 'a' is an array
                dataType: 'json',
                success: function(res) {
    
                    console.log(res);
                }
            });
    
    }
    

    Is your data is in JSON format? If not then you can convert an array into json format using JSON.stringify(a) and post it on server.

    评论

报告相同问题?

悬赏问题

  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大