我是laravel framework的新手。请你帮我找到一个好的解决方案。可能这是一件小事。但我并不是很不幸。
<!DOCTYPE html>
<html lang="en">
<head>
<title>Site</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"> </script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"> </script>
</head>
<body>
<div class="container">
<div class="panel panel-default">
<div class="panel-heading">
<button type="button" class="btn btn-info" id="add">New Site</button>
</div>
<div class="panel-body">
@include('newSite')
<table class="table table-hover">
<caption>Site Info</caption>
<thead>
<th>Site ID</th>
<th>Site Name</th>
<th>Date</th>
<th>Description</th>
</thead>
<tbody>
@foreach($sites as $key => $site)
<tr id="site{{$site->site_id}}">
<td>{{$site->site_id}}</td>
<td>{{$site->site_name}}</td>
<td>{{$site->site_description}}</td>
<td>
<button class="btn btn-success btn-edit">Edit</button>
<button value="btn btn-danger btn-delete">Delete</button>
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
</div>
<script type="text/javascript">
$("#add").on('click',function(){
$('#site').modal('show');
})
</script>
</div>
</body>
</html>
这是我的site.blade.php视图文件。我需要在这个文件中包含newSite.blade.php文件。我使用@include('newSite')行。但它不能正常工作。当我把它放入这个命令不能在代码下面全部工作。请尽快帮助我
答案 0 :(得分:0)
试试这个:
$("#add").on('click',function(){
$.ajax({
method : 'get',
url : '{{ url("/getData") }}',
data :
{
var1 : val1
},
success: function(response)
{
$('#site').html(response); // this response will contain the view returned from getData controller function
// Jquery UI dialog
$('#site').dialog({
title : 'Your Title',
width : 400,
height : 350,
modal : true,
closeOnEscape: false
});
$('.ui-widget-overlay').css('background', 'black');
}
})
});