我正在使用Webix UI模态,这就是我的用法:
this.add = function () {
scrollArea.css("overflow", "hidden");
$.ajax({
type: "GET",
url: "/detail/create",
success: function (form) {
webix.message.keyboard = false;
webix.modalbox({
title: "New detail",
buttons: ["Accept", "Decline"],
text: form,
width: 400,
callback: function (result) {
switch (result) {
case "0":
addDetail();
break;
case "1":
break;
}
scrollArea.css("overflow", "auto");
}
});
}
});
function addDetail() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: "POST",
url: "/detail/store",
data: $('#detail_add').serialize(),
contentType: "JSON",
processData: false,
success: function () {
}
});
}
};
And form's HTML:
<form action="" id="detail_add" method="post">
<input type="text" name="name" placeholder="Name">
<input type="text" name="article" placeholder="Article">
<input type="hidden" name="location_id" placeholder="1">
<input type="hidden" name="_token" value="{{ csrf_token() }}"/>
</form>
当我单击模式接受时,我的JSON为空。我该如何解决?
我试图通过console.log获取输入的值,但是它也是空的。
最佳答案
一般而言,这不是一个答案,但是示例代码不适用于解决问题,因为:
这是稍作更改即可工作并演示您的情况的代码:
我正在使用Webix UI模态,这就是我的用法:
scrollArea = $(window.document);
this.add = function() {
//scrollArea.css("overflow", "hidden");
$.ajax({
type: "GET",
url: "/detail/create",
beforeSend: function(form) {
webix.message.keyboard = false;
webix.modalbox({
title: "New detail",
buttons: ["Accept", "Decline"],
text: form,
width: 400,
callback: function(result) {
switch (result) {
case "0":
addDetail();
break;
case "1":
break;
}
scrollArea.css("overflow", "auto");
}
});
}
});
function addDetail() {
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
type: "POST",
url: "/detail/store",
data: $('#detail_add').serialize(),
contentType: "JSON",
processData: false,
success: function() {}
});
}
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<link rel="stylesheet" href="http://cdn.webix.com/edge/webix.css" type="text/css">
<script src="http://cdn.webix.com/edge/webix.js" type="text/javascript"></script>
<form action="" id="detail_add" method="post">
<input type="text" name="name" placeholder="Name">
<input type="text" name="article" placeholder="Article">
<input type="hidden" name="location_id" placeholder="1">
<input type="hidden" name="_token" value="{{ csrf_token() }}" />
<button onClick="add()">Add</button>
</form>
当我单击模式接受时,我的JSON为空。我该如何解决?
我试图通过console.log获取输入的值,但是它也是空的。
关于javascript - Webix UI模态中的表单数据,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41956593/