Becouse我有很多dinamicly创建的数据(在弹出窗口中)我需要创建像这样的ann函数:
function addOffer() {
var token = document.getElementsByName('_token')[0].value;
var s1 = $('.hstart').val();
var p1 = $('.spin').val();
$.ajax({
url: '/offers',
type: 'POST',
data: {
price: p1,
start: s1,
_token: token
},
});
};
现在我用以下方法调用此函数:
$('.addBid').click(function() {
addOffer();
});
k.cors.a.crossDomain.send @jquery.js:8630
更新 在Laravel后端我只有:
public function store(Requests\OfferRequest $request)
{
$offer = new Offer($request->all());
Auth::user()->offer()->save($offer);
Alert::success('Offer is succesfully added!', 'Good job!')->persistent("Close");
return Redirect::back();
}