Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Answer

Active reading.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134

The simplest solution is to create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to a JSON response
}
function foo(callback) {

 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result);
});

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {

 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result);
});

The simplest solution is to create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to a JSON response
}
function foo(callback) {
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result);
});
deleted 4 characters in body
Source Link
clearlight
  • 12.7k
  • 11
  • 61
  • 82

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {
 
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result); 
}); 

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {
 
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result); 
}); 

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {
 
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result); 
}); 
This is callback function, this may help yiu guys, thank you + code format
Source Link
Milan Baran
  • 4.2k
  • 3
  • 36
  • 51

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {
 
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result); 
}); 

unction foo(callback) { $.ajax({ url: '...', success: function(response) { return callback(null, response); } }); } var result = foo(function(err, result){ if (!err) console.log(result);
}); This is callback function, this may help yiu guys, thank you

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}

unction foo(callback) { $.ajax({ url: '...', success: function(response) { return callback(null, response); } }); } var result = foo(function(err, result){ if (!err) console.log(result);
}); This is callback function, this may help yiu guys, thank you

The simplest solution is create a JavaScript function and call it for the Ajax success callback.

function callServerAsync(){
 $.ajax({
 url: '...',
 success: function(response) {
 successCallback(response);
 }
 });
}
function successCallback(responseObj){
 // Do something like read the response and show data
 alert(JSON.stringify(responseObj)); // Only applicable to JSON response
}
function foo(callback) {
 
 $.ajax({
 url: '...',
 success: function(response) {
 return callback(null, response);
 }
 });
}
var result = foo(function(err, result){
 if (!err)
 console.log(result); 
}); 
This is callback function, this may help yiu guys, thank you
Source Link
Loading
Copy edited.
Source Link
Peter Mortensen
  • 31.3k
  • 22
  • 110
  • 134
Loading
added 2 characters in body
Source Link
Hemant Bavle
  • 3.3k
  • 2
  • 26
  • 30
Loading
Source Link
Hemant Bavle
  • 3.3k
  • 2
  • 26
  • 30
Loading
lang-js

AltStyle によって変換されたページ (->オリジナル) /