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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:25:16+00:00 2026-05-22T23:25:16+00:00

I really can’t work out what’s going on here. I’m using the jQuery load()

  • 0

I really can’t work out what’s going on here. I’m using the jQuery load() method to replace some HTML within a page. In this case it is to replace the current message with one selected from a list by the user.
It’s all working as expected except for one vital thing. When the HTML is returned it has added the word “ARRAY” before anything else. There is no other info (like you would get from var_dump()) and no tags. Literally, just the word in capital letters! If I load the view without using AJAX then it renders as expected. The only difference is that the request was made with AJAX. Here’s the relevant code:

js: (all wrapped in ready())

$('.message_summary').click(function() {
        // get message id
        id = $(this).attr('id');

        // load the new message first so that user can get on with reading it
        $('#message_window').load($.baseurl+'messages/get_message/'+id);

        // mark as read
        $.get($.baseurl+'messages/ajax/mark_as_read/'+id);

        // get current tag id
        $.get($.baseurl+'messages/get_current_tag', 
            function(data){
                            // get the message count
                            $.get($.baseurl+'messages/ajax/set_new_message_count/'+data,
                                    function(msg_count)
                                    { 
                                        $('.new_message_count_'+data).html(msg_count);
                                    }
                                );
            });           
});

CI controller:

 public function get_message($message_id=false)
    {
        if($message_id)
        {               
            // get an individual message and prepare for display
            $message = $this->messages_m->get_single_message($message_id);

            foreach($this->tags['id'] as $index => $tag)
            { 
                $tag_options[$tag] = $this->tags['tag_name'][$index];
            }


            $main_message = array(
                                    'message_id'    => $message_id,
                                    'tag_name'      => $message->tag_name,
                                    'tag_options'   => $tag_options,
                                    'sender' => $message->first_name.' '.$message->last_name,
                                    'date_received' => date($this->config->item('date_time_format'), $message->created_at),
                                    'subject' => $message->subject,
                                    'content' => $message->message
                                );                                    
            if($this->input->is_ajax_request())
            {
                return $this->load->view('partials/message_view', $main_message);
            }
            else
            {
                return $this->load->view('partials/message_view', $main_message, true);
            }
        }

The view file is just HTML with some php variables.

Anyone got any ideas?!?!

  • 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-22T23:25:17+00:00Added an answer on May 22, 2026 at 11:25 pm

    I’m going to try to help you debug in an answer instead of buried in comments.

    We’ve tried if($this->input->is_ajax_request()) exit('Hello'); as the first line of get_message() and the output was Arrayhello. This leads me to believe that somewhere, you are checking for an AJAX request and echoing some array, as this is what will happen if you try to do that.

    My first advice: Go back to your __construct() in the same Controller and do the same thing. If you still get the same result, go back even further, perhaps to a library that is being used. If you don’t see Array anymore, start using the exit code a little further down the road until you find a point where it seems to trigger. FYI since you said you are new to the concept of debugging code, this is not the way to debug, it is just one way.

    Also, it seems from your comment you get Array instead of the uppercase version now? That’s weird, it doesn’t sound right. Make sure you are reading the actual response in Firebug instead of what is visible on screen in your page.

    Aside: A little convenience tip (something I do): Set $this->input->is_ajax_request() as a constant like IS_XHR or AJAX somewhere like in your index, constants file, or config. It just makes it easier to work with. Will the request change from ajax to non-ajax in one request? No. Just check out the source code for it in system/core/Input.php, it’s extremely simple. Example:

    define('AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
    

    This is literally what the Input class does, although it’s a little obfuscated. Now you can just use:

     if (AJAX) do_ajax_stuff();
    

    Just a personal preference, but I find it very helpful – and it’s slightly less resources being used.

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

Sidebar

Related Questions

I'm doing some MonoTouch development, and I really can't figure out an problem I've
Can someone help me work out just what I happening here. I have an
I've done some research and I can't really find a preferred way to do
can anybody recommend some really good resources for how to get Apache authenticating users
I've got a really simple rails question here but I can't seem to find
Extension method is a really helpful feature that you can add a lot of
I tried to google common info about subject, but i really can't find some
ok, I'm going to ask this because I really can not find an answer,
Java is supposed to be write once, run anywhere and it really can be,
Can I really and truly trust .NET to initialize fields (like ints, structs and

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.