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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T18:25:14+00:00 2026-05-14T18:25:14+00:00

I want to execute an ajax call as soon as a document is loaded.

  • 0

I want to execute an ajax call as soon as a document is loaded. What I am doing is loading a string that contains data that I will use for an autocomplete feature. This is what I have done, but it is not calling the servlet.

I have removed the calls to the various JS scripts to make it clearer. I have done several similar AJAX calls in my code but usually triggered by a click event, I am not sure what the syntax for doing it as soon as the document loads, but I thought this would be it (but it’s not):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../js/jquery.js" type="text/javascript">
</script>
<link rel="stylesheet" href="../css/styles.css" type="text/css">
<link rel="stylesheet" href="../css/jquery.autocomplete.css" type="text/css">
<script type="text/javascript" src="../js/jquery.bgiframe.min.js">
</script>
<script type="text/javascript" src="../js/jquery.dimensions.js">
</script>
<script type="text/javascript" src="../js/jquery.autocomplete.js">
</script>
<script type="text/javascript">
  $(document).ready(function(){

          $.ajax({
                type: "GET",
                url: "AutoComplete",
                dataType: 'json',
                data: queryString,
                success: function(data) {
                        var dataArray = data;
                        alert(dataArray);
                        }
                });

     $("#example").autocomplete(dataArray);
  });
</script>
<title></title>
</head>
<body>
    API Reference:
<form><input id="example"> (try "C" or "E")</form>
</body>
</html>

EDIT: my code now looks more like Karim’s:

$(document).ready(function(){
     $.ajax({
        type: "GET",
        url: "../AutoComplete",
        success: function(data) {
             $("#example").autocomplete(data);
        }
     });
 });

Nonetheless the autocomplete still doesn’t work (admittedly another question altogether, so I will also post another question so it has an appropriate title).

My variable “data” that is being sent back looks like … “Manuscript|Text|Information Object|Basketball|Ball|Sporting Equipment|Tarantula”.split(“|”);

If I do

var dataArray = "Manuscript|Text|Information Object|Basketball|Ball|Sporting Equipment|Tarantula".split("|");

and then

$("#example").autocomplete(dataArray);

It all works fine, but when I get the value of dataArray from the server it doesn’t.

  • 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-14T18:25:15+00:00Added an answer on May 14, 2026 at 6:25 pm

    You need to have jQuery loaded before making calls to the jQuery API.

    Before your code snippet, load jQuery…

    <script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to execute a php-script from php that will use different constants and
I want to execute this script (view source) that uses Google Translate AJAX API
I have this function that puts some data with Ajax call in a php
I want a link that when you click on it, it will call a
I want to make a ajax call, that returns javascript that I then need
I've got an ajax call I want to execute for 2 events, whenever the
I want to execute some mysql statements that are stored in a text file
I want to execute a script every 30mins, but i want to use it
I have a large array of vehicle make and model data that I want
I am using ajax call in my classic asp application to execute a stored

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.