2011-03-29 38 views
0

我有一個包含客戶數據的PHP數組。我將在jQuery中修改這個值。然後,O想要用Id(cashup_id)將更改後的值從jquery提交給服務器。請參閱下面的PHP數組。請幫忙。謝謝。如何從PHP和jQuery提交數據到服務器

$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

我們展示JS代碼... – powtac 2011-03-29 10:29:11

+0

你是否看了[AJAX輔助功能(http://api.jquery.com/category/ajax/helper-functions/)jQuery的? – ThoKra 2011-03-29 10:30:17

+0

你將如何從jquery修改PHP數組? – Headshota 2011-03-29 10:31:08

回答

0

@Powtac查看JS代碼。

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); 

}); 
相關問題