ajax how to use global variables?

It is generally taken in the default ajax asynchronous requests, but sometimes need to do a global parameter is common, this time initiated synchronization requests.

as follows:

$.ajax({

  type:"post",

  url: "url Path"

  data:{'name':names},

  async: false, // Note that this property is true by default synchronous request is asynchronous, generally do not write omitted, set the global variable, you add this to the global success of the assignment.

  success::function(res){

    console.log(res)

  }

})

 

ajax (post) request may be used  

$ .Post ( "url access path", {data: Parameter}, function (res) {

  console.log(res)

})the way

Guess you like

Origin www.cnblogs.com/xinyixuan/p/11655700.html