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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:44:21+00:00 2026-06-10T03:44:21+00:00

I have the following code. I am able to call the function titlename and

  • 0

I have the following code. I am able to call the function “titlename” and execute the StatList function to read the CSV file. However I am not able to return any value.From browsing online I found that this question might be related to Ajax, but I donot know Ajax. I want to return the “titles” variable in the following example.

function titlename(title_number)
{   
    jQuery.get('TitleName.csv', function StatList(data) 
    { 
            var titles = new Array();
        var title_array = jQuery.csv(undefined, undefined, '\r\n')(data);
        for (var i=0; i<title_number.length; i++){
            for (var j = 1; j< title_array.length; j++)
            {
                var tmp_compare = title_array[j].slice(0,title_array[j].length-1);
                if(tmp_compare.toString() == title_number[i]){
                    var title = title_array[j][(title_array[j].length-1)];
                    //console.log(title);
                    titles.push(title);
                    break;
                }
            }
        }
        return titles;
    });
}
  • 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-10T03:44:23+00:00Added an answer on June 10, 2026 at 3:44 am

    Since AJAX is asynchronous you cannot simply return the value from a call to titlename. What you could do to use the information once it arrives is call another function and pass in the data you wanted to fetch as an argument. You can either process the data on the spot or process it in the function that you run. For demonstrative purposes, I’ll leave your code where it was.

    Here’s an example of a potential next step:

    var handleTitleData = function(titles){
         // Do whatever you want now that you have the titles
    }
    var titlename = function(title_number){   
        jQuery.get('TitleName.csv', function StatList(data){
             var titles = new Array();
             var title_array = jQuery.csv(undefined, undefined, '\r\n')(data);
             for (var i=0; i<title_number.length; i++){
                 for (var j = 1; j< title_array.length; j++){
                     var tmp_compare = title_array[j].slice(0,title_array[j].length-1);
                     if(tmp_compare.toString() == title_number[i]){
                         var title = title_array[j][(title_array[j].length-1)];
                         titles.push(title);
                         break;
                     }
                 }
             }
             handleTitleData(titles);
        });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: Public Class Form1 Private Function Step1_Execute() As Boolean Return
Issue: not able to close modal dialog I have the following code, it works
I have the following code through which i am able to retrieve phone numbers.
I have the following code that is able to create a class that has
I have the following (simplified) code: var Foo = (function () { var data
I have the following PHP code; <?php component_customer_init(); component_customer_go(); function component_customer_init() { $customer =
I have the following code, which works fine in FF, but the .append() function
I have the following code in an external JS file (ie: test.js); which creates
All, I have the following code: public function addElements() { $newArray = array(); for
I have following piece of code, which should be able to log to console

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.