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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T13:16:50+00:00 2026-06-07T13:16:50+00:00

I added some javascript on my page to update a specific div based on

  • 0

I added some javascript on my page to update a specific div based on the users selection.

I chose this method over simply loading info from the database through PHP because it can be changed on the fly by the user while the page is open through AJAX

The div is the <div id='fight'> div. The function it calls is the update_fight() function found below. I included the entire .js file for reference incase there is something I am missing.

window.onload = (function(){
update_fight();
});

function get_main(page){
     $.ajax({
            type: "POST",
            async: false,
            url: 'http://rickymason.net/d4beta/welcome/loadmain',
            dataType: 'json', 
            data: { page: page },
            success: function(content){
                var html = '';
                html += content['content'];
                $('#main').html(html);
            }
        });    
}

function pop_zone(page){
     $.ajax({
        type: "POST",
        async: false,
        url: 'http://rickymason.net/d4beta/welcome/popzone',
        dataType: 'json', 
        data: { page: page },
        success: function(content){
            var html = $(content['content'])
            var $dialog = $('<div></div>')
            .html(html)
            .dialog({
                    autoOpen: false,
                    title: 'Select Zone',
                    modal: true,
                    width: 800,
                    resizable: false 
            });
            $dialog.dialog('open');
        }
    });     
}
$(document).ready(function() {
    $("#pop_zone").dialog({autoOpen:false});    
});


function update_fight() {
    $.ajax({
        type: "POST",
        async: false,
        url: 'http://rickymason.net/d4beta/welcome/loadmain',
        dataType: 'json', 
        data: { page: 'get_zone' },
        success: function(content){
            var html = '';
            html += content['content'];
            $('#fight').html(html);
        }
    });   
}

function sql_zone(zone) {
    $.ajax({
        type: "POST",
        async: false,
        url: 'http://rickymason.net/d4beta/welcome/sql_zone',
        dataType: 'json', 
        data: { zone: zone },
        success: function(){
            update_fight();
        }
    });   
}

$("#changezone").live('click', function() {
    var page = 'change';
    pop_zone(page);
});


$(".zone").live("click",function() {
    var zone = this.id;
    sql_zone(zone);
    alert ( "Updated: Zone " + this.id );
});

update_fight() calls my controller loadmain: which can be seen here:

    public function loadmain()
    {
        $content = $this->main_model->get_zone();
        $page['content'] = $content;
        echo json_encode($page);
    }

get_zone() can be seen here:

    public function get_zone()
    {
        $user_id = $this->tank_auth->get_user_id();
        $itemroll = $this->db->query("SELECT current_zone, z.name FROM user_load ul
                                    INNER JOIN zones z
                                    ON z.id = ul.current_zone
                                    WHERE ul.user_id = $user_id");
        $result = $itemroll->row_array();
        $zone['current_zone']= $result['current_zone'];
        $zone['name'] = $result['name'];
        //HTML Formatting
        $content = '';
        $content .= "<div id='change'><input type='button' id='changezone' value='Zone'></input></div> ";
        $content .= "<div id='zonename'><a href='". base_url()."welcome/fight'>". $zone['name']."</a></div>";
        return $content;
    }

Is there any glaring issue that might cause this not to work during occasioal page loads, or during a new page load?

This definitely occurs in all 3 browsers, though more consistently in IE7.

  • 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-07T13:16:52+00:00Added an answer on June 7, 2026 at 1:16 pm

    You have jQuery so use it ;).

    change

    window.onload = (function(){
    

    to

    $(function() {
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added some animation using jquery but it's not working: $('.test-container').click(function(){ $(this).css('background-color', 'rgb(119,
I've got a really complicated html page and I've added some bookmark anchors at
At the moment, I have this DIV with a registration form centered over the
I'm making a web based game to teach users some basic Welsh using the
I'm trying to add a jQuery post to some JavaScript on a web page.
I have WebView which loads some page, when it's finished I apply some javascript
I have added a custom form on the opportunity entity and have some javascript
IMPORTANT UPDATE This question was made over 9 years ago. It made sense then,
I am trying to create some javascript that when an object is added to
I have a FireWorks-generated HTML page and I added some jQuery to it for

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.