简体   繁体   中英

Printing server response in an AJAX callback (using jquery)

I have control over my server endpoint

@app.route('/predict', methods=['GET', 'POST', 'OPTIONS'])
@crossdomain(origin='*')

def predict():
  return 'predict12'

I want to return predict12 in the callback of my AJAX call.

$.ajax({
  type: "POST",
  url: 'https://linear-yen-140912.appspot.com/predict',
  data: 'data',
  success: function test(){console.log()},
});

What should I put in the success function so it prints predict12 ?

$.ajax({
type: "POST",
url: 'https://linear-yen-140912.appspot.com/predict',
data: 'data',
success: function test(result){console.log(result)},
});

the success has the result of the AJAX call, and thats what you should be using

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM