OK ho costruito la mia stringa json ma non sono sicuro di cosa fare dopo ??Jquery AJAX post su PHP
$('#submit').live('click',function(){
var dataString = '[';
$('#items tr').not(':first').each(function(){
var index = $('#items tr').index(this);
var supp_short_code=$(this).closest('tr').find('.supp_short_code').text();
var project_ref=$(this).closest('tr').find('.project_ref').text();
var om_part_no=$(this).closest('tr').find('.om_part_no').text();
var description=$(this).closest('tr').find('.description').text();
var cost_of_items=$(this).closest('tr').find('.cost_of_items').text();
var cost_total=$(this).closest('tr').find('.cost_total').text();
dataString += '{"row":"' + index + '", "supp_short_code":"' + supp_short_code + '", "project_ref":"' + project_ref + '", "om_part_no":"' + om_part_no + '", "description":"' + description + '", "cost_of_items":"' + cost_of_items + '", "cost_total_td":"' + cost_total + '"}';
});
dataString += ']';
$.ajax
({
type: "POST",
url: "order.php",
data: dataString,
cache: false,
success: function()
{
alert("Order Submitted");
}
});
});
Nel mio file php stavo tentando di scrivere la datastring in un file di testo in modo ho potuto vedere il suo che passa male, ma niente è stato nel file di testo !? Sto facendo qualcosa di lato client sbagliato o lato PHP, il mio codice php:
<?php
$stringData = $_POST['dataString'];
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, $stringData);
fclose($fh);
?>
Utilizzare Firebug per controllare invece di scrivere su un file. – Petah
Sì, riesco a vederlo bene in Firebug ma volevo solo confermare che il PHP fosse ok ok – benhowdle89