我如何提交一个lararvel表单与jquery(不是ajax),但简单的post与数据(对象或数组)和检索这些数据的方法在控制器
var index = 0;
var seance = [];
$( "#addSession" ).click(function()
{
var session_name = $('#session_name').val();
var session_description = $('#session_description').val();
var session_lieu = $('#session_name').val();
var session_date = $('#session_date').val();
if(seance[session_date])
{
index ++;
seance[session_date][index]= [];
seance[session_date][index]['name']= session_name;
}
else
{
seance[session_date] = [];
seance[session_date][index]= [];
seance[session_date][index]['name']= session_name;
}
console.log(seance);
});
$( '#form-create-event' ).on( 'submit', function(e) {
/* how to add seance to data submitted with the form and how can i get it from the controller */
console.log('submitted');
/*e.preventDefault();*/
console.log(e);
});
做到这一点的最佳方法(不使用一些黑客技巧)是使用XMLhttpRequest,它将发送带有表单和自定义数据的POST请求。为此,可以使用jQuery中的$ajax对象。你可以看看W3School的例子:http://www.w3schools.com/jquery/jquery_ajax_get_post.asp