将刀片文件追加到jquery函数 [英] Append blade file to jquery function
本文介绍了将刀片文件追加到jquery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以做到这一点:
IS there any way to achieve this:
<script>
$('#appends').append('<div class="content-section" id="services">' +
" @include('visitor.pages.services') " +
' </div>');
</script>
我想要的是将 visitor.pages.services
的内容附加到 #appends
div
What i want is to append the content of visitor.pages.services
to #appends
div
visitor.pages.services
不是php网址或其他内容.我只是在自己的主页中包括了几行html.
visitor.pages.services
is not a php url or something. It is just some lines of html where i am including in my main page.
这是文件
<div class="container">
<div class="row">
<div class="heading-section col-md-12 text-center">
<h2>Our Services</h2>
<p>We design mobile-first websites for you</p>
</div> <!-- /.heading-section -->
</div> <!-- /.row -->
<div class="row">
@foreach($data['services'] as $service)
... bla bla
@endforeach
</div> <!-- /.row -->
</div> <!-- /.container -->
推荐答案
正如您的问题所述,您希望获取文件的内容并将其附加到特定元素.
As your question says, you want to get the content of the file and append it to the specific element.
使用 $.get()
Use $.get()
$.get("visitor.pages.service.html", function(data){
$('#appends').append(data);
});
或 .load()
OR .load()
$('#appends').append( $('<div>').load('visitor.pages.service.html'));
或 .ajax()
OR .ajax()
$.ajax({
url: "your.html",
success: function (data) { $('#appends').append(data); },
dataType: 'html'
});
这篇关于将刀片文件追加到jquery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文