Below comes the codes.
function callPublish(authorId){
var _shareDetail = artEditor.getContent();
document.getElementById("shareAuthorIdInput").value = authorId;
document.getElementById("shareDetailInput").value = _shareDetail;
var detailData = {
data:JSON.stringify({
"shareTitle":$("#shareTitleInput").val(),
"shareAuthorId":$("#shareAuthorIdInput").val(),
"shareDetail":$("#shareDetailInput").val()
})
};
$.ajax({
url:"/pubShare",
type: 'POST',
data: detailData,
success: function (msg) {
alert(msg);
status = msg;
}
});
return status;
}
The variable "status" was defined before function callPublish()
.
I want to assign the returned value to the global variable "status".I try to add this into ajax: "async:false"
,and surprisingly,it works.
But it is not asynchronous.So how can I make it work,not using "async:false"
?
Thanks, my English is not so well,hoping you can get what I mean.