这是我的路线档案
interface LayoutInterface {
getLayout();
}
class LayoutEnglish implements LayoutInterface {
getLayout() {
return {'Q', 'W', 'E', 'R'...};
}
}
class LayoutNumeric implements LayoutInterface {
getLayout() {
return {'1', '2', '3', ...};
}
}
class LayoutComponent {
@Input
type: 'english';
getLayout(type) {
// what about dynamic import here?
return new {Layout+type};
}
}
keypad.component.html
<app-keypad type="english"></app-keypad>
这是我的jquery ajax代码
Route::post('/ajaxdemo', 'DemoController@saveAjax');
当我提交表单时,ajax请求转到控制器方法
$('#record_form').on('submit', function (e) {
e.preventDefault();
var select_form = $('#select_form').serialize();
$.ajax({
type: "POST",
url: '/ajaxdemo',
data: {
mydata: select_form,
},
dataType: 'json',
success: function (data) {
console.log(data);
}
});
});
我从public function saveAjax(Request $request)
{
$data = $request->all();
dd($data);
}
调用ajax函数,页面只是刷新并在/demo/create
中显示token
。即使我正在做dd($ data)
答案 0 :(得分:0)
请试试这个:
<input type="text" id="result">//treat this as location 2
<div id="map" style="width:100%;height:200px;background:yellow;" frameborder="0" style="border:0"></div>
<script>
function myMap() {
var mapOptions = {
center: new google.maps.LatLng(15.835015,74.517537),
zoom: 25,
mapTypeId: google.maps.MapTypeId.HYBRID
}
var map = new google.maps.Map(document.getElementById("map"), mapOptions);
var marker = new google.maps.Marker({
position: GIT,
map: map
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=&callback=myMap"></script>
</input>
</form>
答案 1 :(得分:0)
$.ajax({
url:$("#select_form").attr('action'),
dataType:'json',
type:'POST',
data:$("#select_form").serialize(),
success: function(data) {}
});
答案 2 :(得分:0)
如果你想通过ajax laravel显示数据。你可以通过打开inspect-&gt;网络检查数据响应或dd($ data)并再次运行ajax。你可以看到任何数据或错误
也许您的请求错误500可由https://laravel.com/docs/5.5/csrf
修复