1
我得到兩個變量在我的jQuery的功能以及如何通過它在我的數據AJAX調用內部並把它在laravel控制器傳兩人在jQuery函數的AJAX數據調用內部變量
這是我的功能
$('#updateProduct').on('submit', function(e){
e.preventDefault(e);
var redirect_url = $(this).find("[name='redirect_url']").val();
var url = $(this).attr('action');
var method = $(this).attr('method');
var videos = document.getElementById('videoToUpload').files[0];
var myData ={
'name': $(this).find("[name='name']").val(),
'description': $(this).find("[name='description']").val(),
'brand': $(this).find("[name='brand']").val(),
'category': $(this).find("[name='category']").val(),
'condition': $(this).find("[name='condition']").val(),
'shipper': $(this).find("[name='shipper']").val(),
'shipping_from': $(this).find("[name='shipping_from']").val(),
'shipping_paid_by': $(this).find("[name='shipping_paid_by']").val(),
'shipping_within' :$(this).find("[name='shipping_within']").val(),
'shipping_weight': $(this).find("[name='shipping_weight']").val(),
'shipping_fee': $(this).find("[name='shipping_fee']").val(),
'seller_get' : $(this).find("[name='seller_get']").val(),
'price_per_unit': $(this).find("[name='price_per_unit']").val(),
'selling_fee' : $(this).find("[name='selling_fee']").val(),
'is_active':$(this).find("[name='is_active']:checked").val(),
//'videos' :$("#videoToUpload").files[0],
//'videos' : document.getElementById('videoToUpload').files[0],
}
console.log(data);
$.ajax({
type: method,
url: url,
dataType: 'JSON',
data: {'myData':myData
'videos':new FormData("videos", document.getElementById('videoToUpload').files[0])
},
success: function(data){
alert("Products updated successfullly");
console.log(data);
//window.location.href = redirect_url;
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(JSON.stringify(jqXHR));
console.log("AJAX error: " + textStatus + ' : ' + errorThrown);
}
});
我在這裏有兩個變量一個videos
等myData
現在我的問題是,如何通過數據這兩個變量和laravel控制器
把一個逗號後' 'myData':myData' – RST
你可以把視頻放在myData下。 – Webinion
@PandhiBhaumik當我給這樣的它顯示我一個錯誤'未捕獲的類型錯誤:非法調用' – Karthiga