weixin_33688840 2016-06-19 21:55 采纳率: 0%
浏览 7

简化ajax对象

I have this function to write the inputs from a form to the database and i'm trying to simplify the data being passed by the ajax call to the php. Currently i have this function:

function writeDB(stage){
    var userData = $("#cacheDB").find("input").get();
    var ajaxData = []
    for (var n=0;n < userData.length; n++){
        item = {};
        item[userData[n].id] = userData[n].value;
        ajaxData.push(item);
    }

    $.ajax({
        url: "x.php",
        data: {ajaxData},
    });
}

Which sends out this object:

http://url.php?ajaxData[0][pageid]=1&ajaxData[1][input1]=John&ajaxData[2][input2]=Doe

I would like to send only the original data key, like:

http://url.php?[pageid]=1&[input1]=John&[input2]=Doe

Or

http://url.php?pageid=1&input1=John&input2=Doe

Is it posible? I've tried several methods and havn't found one suitable yet.

  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 c++字符串分割问题
      • ¥15 关于#sql#的问题:没有用命令关闭cdc,手动把系统表开启的cdc右键删除了
      • ¥15 vue+uniapp
      • ¥15 android freedom
      • ¥15 使用自定义的类型代替内置类型可行吗
      • ¥15 关于STM32的SPI和ENDAT接口编码器通信的问题
      • ¥15 关于#pdfbox#生成的PDF文件正常,转图片中文乱码的问题,如何解决?
      • ¥15 ADS中有关DAC控件的使用问题
      • ¥15 win11如何运行geoserver
      • ¥15 审稿意见请教-用ERNIE进行小样本分类的对比实验问题