I am currently working on implementing a function that will perform an action based on the response text received from a specific ajax call. However, I am struggling to access the response text field in my code. Here is the snippet:
var response = $.getJSON('/add_participant',{
email : uemail,
password : upassword
})
I have attempted to access it using this method:
response.responseText
Nevertheless, when I try to log it out to the console, it shows as undefined.
I believe the issue lies in the fact that the ajax call needs to resolve first before I can access the response text. This hypothesis is supported by the fact that if I save it to a global variable, I am able to access the responseText when using inspection tools on the webpage.
Is there a way for me to retrieve that response text within my function? Can I make the script wait for it to resolve? Any suggestions would be greatly appreciated!
Thank you in advance!