Laravel & Bootstrap ajax modal example
// html
<div>This is my post</div>
<!-- Just put this div at the bottom of your template somewhere-->
<!-- Notice that its hidden by default, so if it doesnt get used, thats fine-->
<div class="modal hide"></div>
//JS
$.ajax({
type: 'post', // or post?
dataType: 'json',
url: SITE_BASE + uri, // change as needed
data: requestData, // if you are posting
success: function(data) {
if (data.success) {
// notice that we are expecting a json array with success = true and a payload
$('.modal').empty().append(data.payload).modal();
} else {
// for debugging
alert(data);
}
},
error: function(xhr, textStatus, thrownError) {
alert(xhr.status);
alert(thrownError);
}
});
//php
return Response::json(array('success' => true, 'payload' => View::make('posts.item'))