I created this synchronous Ajax function to simply post data:
function postme(id, tt) {
tt['id'] = id;
$.ajax({
async:false, type: 'post', url: 'post.php', data: tt,
success: function(response){ console.log(response);return response; }
});
}
The response is: {"Info": "aoaaa"}
The console.log(response);
provides the JSON in the console, but the return gives a 'undefined'. I tried calling it like this:
postme('generate', {'1':'ee','w':'yy'});
I tried JSON parse, giving the function a name I tried everything I could found online but it just does not work.
I've looked at How do I return the response from an asynchronous call? but that does not seem to work for me since the function does not send variables like mine, it will just do foo();
or postme();
in my case. How do I do this with vars?
Edit: I do not NEED to use async, if there is a better code to not use it, I would rather use it.