M
M
Max Ba2016-12-05 13:04:38
JavaScript
Max Ba, 2016-12-05 13:04:38

Why is FancyBox bringing up the page?

Guys, what is the reason that the content after clicking and displaying raises the page?
BUTTON TO OPEN PRODUCT PREVIEW/div>

$(document).on("click", ".preview", function(){

var id = $(this).attr('id');

$.ajax({
  type: 'post',
  data: 'id=' + id,
  url: '/ajax/preview.php',
  success: function (data){
    $.fancybox(data); //data = '<div id="#preview_item">HTML CODE</div>'
    return false;
  },
  error: function(){
    alert('fatal error');
  }
});

return false;
  
});


Jquery version 1.9.0
FancyBox 2.1.5

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2016-12-05
@phpcoder81

Wang that the body has a height of 100%, remove it and everything should be ok.

W
WQP, 2016-12-05
@WQP

$(document).on("click", ".preview", function(event){
event.preventDefault()
....
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question