Pass parameters? Judge? Judge the parameters?

var uid = users.id;     
console.log(uid);//ID
console.log(returnCitySN["cip"]);ip

if (uidsand undefined) {}
$(function () {
/ page rendering /
$.ajax ({

)
type:"POST",
 dataType: "json",

url: "URL",
data: {ip:returnCitySN ["cip"]}, this is the parameter to be passed.

now I want to make a judgment. If you can get the user"s id, you should wear data: {uid:uid};
if you can"t get the user"s id, send data: {ip:returnCitySN ["cip"]};
ask God for help?

Mar.01,2021


var aData;<br>if(uid){

aData={uid:uid};

} else {

aData={ip:returnCitySN["cip"]};

}
$.ajax ({

)
data:aData

});

Menu