Hi
I don't find the right solution for an Ajax submit through a form. I want to save the data in the database.
This is the jquery and this works...but the save works not
jQuery.noConflict();
(function($) {
$(document).ready(function() {
$("#ProductForm_ProductForm").submit(function() {
var Productcategory = $("#ProductForm_ProductForm_Productcategory").val();
var Productsubcategory = $("#ProductForm_ProductForm_Productsubcategory").val();
var Product = $("#ProductForm_ProductForm_Product").val();
var Price = $("#ProductForm_ProductForm_Price").val();
var Einheit = $("#ProductForm_ProductForm_Einheit").val();
var Description = $("#ProductForm_ProductForm_Description").val();
var Anzeige_von = $("#ProductForm_ProductForm_Anzeige_von").val();
var Anzeige_bis = $("#ProductForm_ProductForm_Anzeige_bis").val();
var SecurityID = $("#ProductForm_ProductForm_SecurityID").val();
var dataString = 'Productcategory='+ Productcategory + '&Productsubcategory='+ Productsubcategory + '&Product='+ Product + '&Price='+ Price + '&Einheit='+ Einheit + '&Description='+ Description + '&Anzeige_von='+ Anzeige_von + '&Anzeige_bis='+ Anzeige_bis + '&SecurityID='+ SecurityID;
//alert (dataString);return false;
$.ajax({
type: "POST",
url: "",
data: dataString,
success: function() {
alert(dataString);
}
});
return false;
});
});
})(jQuery);
this works not:
public function saveproduct(array $data, Form $form) {
parse_str(urldecode($this->requestParams['Product']),$data['Product']);
$p = $data['Product'];
// Debug::show($data);
$memberID = Member::currentUserID();
Session::set('product',$data['Product']);
$customerproduct = new Customerproduct();
$customerproduct->write();
$form->saveInto($customerproduct);
$customerproduct->CustomerID = $memberID;
$customerproduct->Product = $p;
$customerproduct->write();
Director::redirectBack();
return $form->sessionMessage('Ihr Produkt wurde gespeichert.', 'good');
}
Has somenon a tipp? I tried the other tipps here in the forum but it does not work. When I yous serialize then I have the code of the whole website.
Tanks for help!