drt96856 2011-03-29 10:27
浏览 23

如何从PHP和jQuery向服务器提交数据数组

I have an array of PHP with customer data. I will modify this values in jQuery. Then O would like to submit the changed values with an Id (cashup_id) to the server from jquery. Please see the PHP array below. Please help. Thanks.

$Cashups = array(
  array(
    'cashup_id' => 146456,
    'display_time' => 'Wed 16th Mar, 9:55pm',
    'terminal_name' => 'Bar 1',
    'calculated_cash' => 389.20,
    'actual_cash' => 374.6,
    'calculated_tenders_total' => 1,551.01,
    'actual_tenders_total' => 1,551.01
  ),
  array(
    'cashup_id' => 146457,
    'display_time' => 'Wed 16th Mar, 9:56pm',
    'terminal_name' => 'Bar 2',
    'calculated_cash' => 493.3,
    'actual_cash' => 493.3,
    'calculated_other' => 1509.84,
    'actual_other' => 1509.84
  )
);
  • 写回答

1条回答 默认 最新

  • dsfdsf21321 2011-03-29 11:17
    关注

    @Powtac see the JS code.

    jQuery(function($) {
    
    $(".Cashups").delegate("td:eq(3) > a", "click", function(event) {
    var a, parent, input, doneLink, b, i, eq, c, d;
    var eq = $(this).parent().children("a").index(this);
    
    // The `a` has been clicked; cancel the action as
    // we're handling it
    event.preventDefault();
    event.stopPropagation();
    
    // Remember it and its parent
    a = $(this);
    parent = a.parent();
    
    // Insert an input in front of it, along with a done link
    // because blur can be problematic
    input = $("<input type='text' size='10'>");
    input.insertBefore(a);
    input.blur(doneHandler);
    doneLink = $("<a href='#'>done</a>");
    doneLink.insertBefore(a);
    doneLink.click(doneHandler);
    
    // Put the text of the link in the input
    input.val(a.text());
    
    
    // Temporarily detach the link from the DOM to get it
    // out of the way
    a.detach();
    
    // Give the input focus, then wait for it to blur
    input[0].focus();
    
    // Our "done" handler
    function doneHandler() {
    // Replace the content of the original link with
    // the updated content
    a.text(input.val());
    
    b = a.text();
    //c = b;
    alert(b);
    
    
    $.get('js_test.php?b=' + b, function (data) {                                     
    
        $('.Cashups td a').eq(3).html(b);
    
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100
  • ¥15 关于#hadoop#的问题
  • ¥15 (标签-Python|关键词-socket)
  • ¥15 keil里为什么main.c定义的函数在it.c调用不了
  • ¥50 切换TabTip键盘的输入法