douzangdang2225 2014-05-07 15:20
浏览 40

Ajax发布错误文本字段

I can not figure out how to get the text from my text field login_ConfigPostken to be sent through my POST ajax request. For this POST I need to send over the key_id, which is in the format of {"xtalk.user": "test"}. The format of the message to be typed into my text field in {"<name of key>": "<value>"}


Code:
$('#sumbit_configPost').on 'click', ->
username = $('#login_username').val()
password = $('#login_password').val()
mac_id = $('#login_ConfigPostmac').val()
key_id = $('#login_ConfigPostkey').val()
console.dir key_id
console.dir data
$.ajax
  type: "POST"
  url: start_url + mac_id + "/config/"
  dataType: "json"
  data: {key_id}
  crossDomain: true
  cache: false
  beforeSend: beforeSend

  success: (data) ->
  ... Code Continues

Thank You In Address

  • 写回答

2条回答 默认 最新

  • dongque20030402 2014-05-07 15:26
    关注

    This isn't a valid key/value pair:

    data: {key_id}
    

    Maybe you mean something like this?:

    data: {"key":key_id}
    

    The key_id value itself needs some kind of key within the data so it can be referenced. That key here is just the string "key" but could be anything you need, depending on how you're expecting to reference it in the server-side code. In this case it would be something like:

    $_POST['key']
    
    评论

报告相同问题?

悬赏问题

  • ¥15 mmocr的训练错误,结果全为0
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀