I've been searching for an answer on this one, but none of the answers I found help resolving this issue:
HTTP Post via jQuery is not returning any data.
Here is the javascript code:
$.post(
    <ENDPOINT_URL>,
    <XYZ DATA SENT>, 
    function(data){
        //THIS IS THE PROBLEM HERE
    },
    "json")
    .fail(function(jqXHR, textStatus, errorThrown){
        alert(textStatus);
    });
This calls my endpoint API Url fine, which returns code 200 and a JSON response body:
{message: "XYZ"}
So here is what I've done so far:
- Because of the asynchronous behavior, I created a function to receive and process the data input. Nothing happens still.
- Added the .fail to process failures. According to an article my JSON returned may be incorrectly formatted and placing that .fail to process a failure may let me know what's going on... Is there a way to get the actual error message details?
- Validated my JSON. Is it incorrectly formatted or something I'm not realizing?
- Replaced the entire code with $ajax instead. Still, getting the same error.
I want to be able to receive that response and process the message "XYZ".
Thank you everyone for your help, much appreciated.
Tutorials/Articles I've followed:
https://api.jquery.com/jquery.post/
 
     
     
    
