I’m trying to take values from a table and put them into a string and send them to a php page for logging to a database, however there will be multiple rows need to be inserted so i need to split the values into multiple strings to send if that makes (any) sense?
This is my jQuery:
$('#submit').live('click',function(){
var supp_short_code=$('.supp_short_code').text();
var project_ref=$('.project_ref').text();
var om_part_no=$('.om_part_no').text();
var description=$('.description').text();
var cost_of_items=$('.cost_of_items').text();
var cost_total=$('.cost_total').text();
var dataString = 'string=//' + supp_short_code + '//' + project_ref + '//' + om_part_no + '//' + description + '//' + cost_of_items + '//' + cost_total
$.ajax
({
type: "POST",
url: "order.php",
data: dataString,
cache: false,
success: function()
{
alert("Order Submitted");
}
});
});
but what i’m saying that there may be 2 or 5 or 12 values in each of the variables!? My plan is to send a string to the php, get the php to parse the values between the “//” and to insert them into separate variables for a mysql query. If someone can think of a better way to do this, please tell me!!!
Transport it as JSON string.
Now this means you have to go through the rows one by one. Select on all the rows and construct your datastring one line at a time, by appending onto the JSON string. This will make the PHP parsing much easier.