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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:30:40+00:00 2026-05-24T08:30:40+00:00

I want to be able to call a function from the on success region

  • 0

I want to be able to call a function from the “on success” region instead of having to place my code in that region. I’ll be using the code twice so I’m trying to figure out how to place it outside of the jQuery.ajax() function.

Here is my current code:

$.ajax({
  type: "GET",
  url: "ws/getweather.ashx?zip=" + vZip,
  dataType: "xml",
  success: function (xml) {
  $(xml).find('weather').each(function () {
     // Load New Data
     ...
});
},
  error: function (xml) {
    alert("Unrecognized Region. Please try again.");
  }
});       

So instead of having…

function (xml) {
  $(xml).find('weather').each(function () {
     // Load New Data
     ...
});

I’d like to put the name of another function, and pass the xml to that function. That way I can have other events call the same set of code.

Thanks in advance!

UPDATE===================================================

Thanks to Mike Richards for his timely response. I’m including the exact syntax below because I had to add a few details to make it work…meaning, pass the XML to the other function.

$.ajax({
type: "GET",
url: "ws/getweather.ashx?zip=32751",
dataType: "xml",
success: function (xml){
    weatherize(xml);
},
error: function (xml) {
    alert("Unrecognized Region. Please try again.");
}
});

And then somwhere below, my other function

function weatherize(xml) {
  $(xml).find('weather').each(function () {
// Load New Data
...
})
};
  • 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-24T08:30:41+00:00Added an answer on May 24, 2026 at 8:30 am

    you can just pass in a function for that parameter 🙂

    success : successFunction,
    

    and then, somehwere else:

    function successFunction(data) {
      // Do Something
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary I want to be able to call a JavaScript function from a Flex
I want to be able to call a global function from an imported class,
I'm having problems trying to call a Javascript function from an enqueued javascript file
I want to be able to call a function from a link (this function
I want to call specific php function on server from Android application and also
I'm trying to figure out how to call a c function from an obj-c
I'm trying to make a list of function calls. I want to be able
I want to be able to make an HTTP call updating some select boxes
I want my app to be able to tell whether a call was missed,
I want to stop outgoing call and open the application. The app is able

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.