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 6878713
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:45:27+00:00 2026-05-27T04:45:27+00:00

My index.php has a jquery ajax call that inserts getposts.php into my #content div.

  • 0

My index.php has a jquery ajax call that inserts getposts.php into my #content div. This works fine.. The problem is that getposts.php has some javascript (more jQuery) in it and while Chrome does execute the code fine, Firefox doesn’t.

If I include the javascript as a file (setchecked.js) firebug is looking for setchecked.js_=1322020697832

If I include the javascript directly into getposts.php, the javascript is completely ignored (it doesn’t even show up in the source code)

Does anyone know why and how to fix it?

index.php

<script type="text/javascript" src="fetchposts.js"></script>
<div id="content"></div>

fetchposts.js

$(document).ready(function() {
$.ajax({
    url: 'getposts.php',
    type: 'POST',
    success: function (fetched) {
        $('#content').load('getposts.php');
    },
});
});

getposts.php (this makes firebug look for setchecked.js_=1322020697832

<script type="text/javascript" src="setchecked.js"></script>

or getposts.php (the javascript is completely absent from the source code)

<script type="text/javascript">
$(document).ready(function() {
// set $checked values
$.ajax({
    url: 'query.php',
    type: 'POST',
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    async: true,
    cache: false,
    success: function (msg) {
        ------ do some fun stuff that works --------
    },
});
});
</script>
         --------------- some php and html that DOES display -------------

Again, my problem isn’t the content of my javascript, but how to get the javascript to work within the #content. Chrome does execute the code without problem. For some reason, it is firefox being picky. Firebug reports no errors, other than looking for the wrong file or completely ignoring it.

The rest of getposts.php (the html and php code) DOES display inside my #content in both Chrome and Firefox.

  • 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-05-27T04:45:27+00:00Added an answer on May 27, 2026 at 4:45 am

    I know that the scripts are working, but I think that they need some refactoring.
    From the code I see that you are

    1. Loading content from getposts.php into the #content
    2. Once loaded, you want to get some JSON
    3. When JSON is loaded, you want to some fun stuff with it

    The code can be improved by:

    • Not making so many ajax calls
    • Using specialized, ajax methods specifically for each task
    • Putting them within a single file

    fetchposts.js

    $(document).ready(function() {
        var someFunStuff = function(msg) {
            // do some fun stuff that works 
        };
    
        var setChecked = function() {
            $.getJSON('query.php', someFunStuff);
        };
    
        $('#content').load('getposts.php', setChecked);
    });
    

    If I’ve misunderstood something that you want to get done or you have some more specifications that need to be introduced, let me know and I will respond as needed.

    Update

    I see a comment that you’ve made about using a single javascript file. What is it that you are needing to get from the separate database?

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

Sidebar

Related Questions

index.php has this jquery code which loads notifications.inc.php into a div on the page
My PHP site has header,body,footer files that are included into the INDEX.PHP page. On
I'm having some issues with a jQuery AJAX call. My code works fine when
I have this page, let's call it index.php index.php has a list of users
Information: I have a site that has a design on index.php, and then you
I have a index.php file that will include several external files: content/templates/id1/template.php content/templates/id2/template.php content/templates/id3/template.php
I have a set of jQuery UI tabs that each load project.php using ajax.
I have an index.php file which has to process many different file types. How
Coles Notes version: index.php?map_id=foo is loaded into iframe on www.not-my-domain.com. index sets SESSION['map_id'] =
how can i redirect index.php?search= to the base url? I tried it with this

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.