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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:59:32+00:00 2026-06-03T04:59:32+00:00

I have 2 JS files, one containing a list of generic functions to be

  • 0

I have 2 JS files, one containing a list of generic functions to be shared between multiple files called “form.js”, and another specific to a certain page on my CMS called “blog.form.js”.

Inside “form.js”, I have a generic JS function that makes a jQuery.ajax() request whenever I’ve requested to load a record from the database:

function load_record( field_id, class_name, entity_type ) {

// Send ajax request to load the record, and enable the form's state once the record's content has been received.
var response = $.ajax({
    async: false,
    dataType: "json",
    data: {
        action: "load_"+entity_type,
        id: $("#"+field_id+"_list").val()
    },
    success: function(response) {
        // Make visible the buttons to allow actions on record, such as deleting or renaming.
        $("#"+field_id+"_actions").show();

        // Make visible the container of all form elements related to the record.
        $("#"+field_id+"_form_inputs").show();

        // Must return response so the calling JS file can use the values returned to
        // populate the form inputs associated with the record that's just been loaded
        // with the correct values.
        return response;
    },
    type: "post",
    url: "/ajax/record/"+class_name
});
alert( response.link + " " + response + " " + response.responseText);
return response;

}

Inside “blog.form.js”, I have function called when I select a database record to load from a menu containing a list of them:

// Select a link for editing.
$("#links_list").live( "change", function(){ 
    // Insert response returned from function call to load the db record into a variable.
    // This is so the form inputs associated with the record loaded can be populated with the correct values. 
    var response = load_record('links_edit', 'blog', 'link'); 
    alert( response.link );
    $("#links_edit_url").val( response.link );        
});

The ajax request returns the desired response. Unfortunately, the debug alert statement “alert( response.link + ” ” + response + ” ” + response.responseText)” inside load_record() returns the following: undefined [Object XMLHTTPRequest] {“link”: “http://www.url.com”}.

Thus, the debug alert statement “alert( response.link )” in the other function returns undefined as well.

An XMLHTTPRequest object is returned successfully. So, why is response.link stating its value is undefined?

Any help is much appreciated.

  • 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-03T04:59:33+00:00Added an answer on June 3, 2026 at 4:59 am

    You were totally on the right track, and you can make a function that returns an ajax object. jQuery returns that ajax call as a Deferred object – so it has extra methods on it to tap into the ajax response after the fact.

    $("#links_list").live( "change", function(){ 
        load_record('links_edit', 'blog', 'link').done( function( response ) {
            alert( response.link );
            $("#links_edit_url").val( response.link );     
        });
    });
    

    The alert( response.link + " " + response + " " + response.responseText); in load_record will keep returning as it has been unless you add it to the success or done handlers.

    Take a look at Deferreds on jquerys site with the link above if you need some more info on what .done() really is. I hope this helps.

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

Sidebar

Related Questions

I have two files. file1 has the data like belowing containing only one column.
I have two tables in Sql Server, one containing IDs for files and the
I have three files: one called sql.php witch has a class db that I
I have two template files: one for the form (loginFormTemplate) and one for the
At some point I must have moved files from one location to another using
I have this code to open multiple files one at a time that is
I have two files, one containing an array in PHP that is echo ed
I have a file containing a list of hexadecimal numbers, as 0x12345678 one per
I have to parse several comma-separated files containing headers via a generic parser. The
I am interested in one topic, suppose that we have eight file, each containing

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.