【发布时间】:2020-03-23 10:04:07
【问题描述】:
我正在使用 Laravel 和 jquery。我有电子商务,我有我的产品列表,其中一些在我的网站上,其中一些我不需要 重定向在我的网站内的产品和 其他人打开一个新标签。 例如:
<a href="www.MYWEB.COM" > MY PRODUCTS</a>
<a href="https://www.w3schools.com" target="_blank"> Producs from other website </a>
有可能吗?到目前为止,我有这个。我真的需要帮助。
<div class="dropdown-menu dropdown-menu-right">
<div class="header-items">My Products<span class="count-items ml-1">{{count($notifications)}}</span></div>
@foreach ($notifications as $item)
<a href="{{ $item->url }}" class="idNote" data-note="{{ $item->id }}" style="color: #000000;" data-redirect="{{$item->url}}">
<div id="note-{{ $item->id }}" class="item {{$item->isOpen? 'not-read' : '' }}" >
<p class="mb-0 font-medium">{{ $item->titulo }}</p>
<p class="mb-0">{{ $item->texto }}</p>
<span class="point-not-read"></span>
</div>
</a>
@endforeach
</div>
我的 jquery
<script>
$('.idNote').click(function(e){
e.preventDefault();
var noteId = $(this).attr('data-note');
var redirecTwo = $(this).attr('data-redirect');
console.log(noteId);
$.ajax({
url : "{{ route('readit') }}",
type : "POST",
data : {
jsNoteId : noteId
},
beforeSend : function(){
$('#note-'+noteId).removeClass('not-read');
//window.location = redirecTwo;
window.open(redirecTwo, '_blank');
},
success : function(r){
console.log(r);
}
});
});
</script>
【问题讨论】:
标签: jquery html laravel-5 redirect http-redirect