Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8008959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:18:08+00:00 2026-06-04T18:18:08+00:00

I am having an issue closing a fancybox popup when jquery is included within

  • 0

I am having an issue closing a fancybox popup when jquery is included within the popup page (i’m using AJAX and including an external php page within the popup). The fancybox is setup as follows:

$(".various3").fancybox({
'type'    : 'ajax',
'titlePosition'     : 'inside',
'transitionIn'      : 'none',
'transitionOut'     : 'none',
'ajax' : {
type        : 'GET'
}
});

The popup has a ‘Cancel’ button to allow users to close the popup (using jQuery.fancybox.close();). I have to include jquery within the popup page to allow some other functionality to work and this prevents the jQuery.fancybox.close(); from working. If i remove jquery from the popup page then it works fine, however I cannot work out how to reference the instance of jquery on the main page (i have tried parent in case, although i wouldn’t have thought this should work as it’s a div and indeed it didn’t). I have tried using:

var localjquery = jQuery.noConflict(true);

within the popup page and this allows me to use jQuery.fancybox.close(); to close the popup successfully however this prevents the use of $ to reference jquery which is needed for other plugins on this page that i can’t edit. If I add

var mainjquery = jQuery.noConflict();

after the first instance of jquery on the main page then this obviously works fine and i can refer to it as mainjquery on the parent, but if then try

mainjquery.fancybox.close();

on the popup it says mainjquery is undefined.

I suspect it’s a problem due to a combination of multiple jquery instances and loading a completely separate page via ajax into a div (rather than using an iframe etc whereby i could then use parent. or similar). If anyone could shed any light on how I could reference the mainjquery reference from the child popup, or a better way I can close the fancybox then that would be greatly appreciated.

Thanks so much!

Dave

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T18:18:10+00:00Added an answer on June 4, 2026 at 6:18 pm

    The best thing to do is test to see if it is an ajax request, and if so don’t include the jquery (or any other scripts you already have for that matter).

    Here’s a sample of code I use on my php pages for doing both ajax and regular page requests.

    define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && 
    strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest');
    ....
    if(!IS_AJAX)
    {
        //echo your header with scripts
        echo $header;
    }
    //else just echo the contents of the page body
    

    edit:

    If you need to add things to the head tag, you should be using an iframe instead of an ajax type for the fancybox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am having issue with loading my selector via a jquery ajax load call
Having a jQuery dialog issue. I want to leverage ajax to render calendar content
Having an issue with traversing in jQuery.. hopfully an easy one..but I'm banging my
having same issue, i am totally new in php. i install XAMPP then download
Im having an issue where the my jquery UI dialog loads multiple times on
I am having an issue with caching the home page of my Asp.Net Mvc
I'm using jquery to animate a bit my web site, but I'm having a
EDIT: I am having an issue with reloading a div on a parent page
I'm having an issue where my combobox is losing its SelectedIndex value upon closing
I am having an issue with some Jquery script that I have and I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.