Good afternoon,
We are doing an jquery ajax call with the .serialize() function. We are doing this because the form has multiple columns/rows that we would like to save with one call to ajax. The serialize function takes all the pertinent form data and serializes it. Here is what gets sent to the php ajax call.
$.ajax({
type: "POST",
url: "ajax/SaveClaimParts.php",
data: {
'ClaimID': $('.hdn-claim-id').val(),
'Parts': $('.parts-form').serialize()
},
dataType: "json",
success: function(data)
{
console.log("Happy");
},
error: function()
{
console.log("An error occurred while processing the save.");
}
});
This works great because when I see what gets sent to the server to be processed looks something like this.
claim_part_no=12349&claim_part_desc=TUBE&claim_part_no=85555&claim_part_desc=BRACKET
Please note the duplicated part_no and part_desc. This is not a mistake but rather the fact that there are 2 rows that we want to submit. Each row contains a part # and a part desc.
The question now is how do I break this string up in php so that it can be saved/inserted row-by-row.
Here is what I have tried:
$Parts = $_POST['Parts'];
$PartsArray = array();
parse_str($Parts, $PartsArray);
This works but it only has the last row in $PartsArray. Any help would be much appreciated.
Thank you. George Eivaz