Question

2
Replies
628
Views
Chinna Kumar (Chinna)
Mindtree Ltd

Mindtree Ltd
IN
Chinna Member since 2018 10 posts
Mindtree Ltd
Posted: March 25, 2018
Last activity: May 2, 2018
Posted: 25 Mar 2018 7:34 EDT
Last activity: 2 May 2018 1:50 EDT
Closed

Unable to post data to server using XMLHttpRequest

Hi Team,


Actually I am trying to hit the server to post data(XML) from PEGA using XMLHttpRequest but I am getting the Http Status as "0" .Below event listener(onreadystatechange ) is not executing and send is failing with the message: callUrl.launchScreen(): Unexpected error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load "URL".


Code:

Show More

Hi Team,

Actually I am trying to hit the server to post data(XML) from PEGA using XMLHttpRequest but I am getting the Http Status as "0" .Below event listener(onreadystatechange ) is not executing and send is failing with the message: callUrl.launchScreen(): Unexpected error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load "URL".

Code:

function invokeInsertClaim(insertClaimXml)
{
try {
alert("callUrl.launchScreen(): screenInputXML=" + insertClaimXml);
var xmlhttp = new XMLHttpRequest();
xmlhttp.open("POST","url",false);
xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState === 4) {
if (xmlhttp.status === 200) {
alert("Done with status: " + xmlhttp.status + " and statusText: " + xmlhttp.statusText);
alert('xmlhttp.responseText: ' + xmlhttp.responseText);
return null;
} else {
var statusText = getErrorMsg(xmlhttp.status, xmlhttp.statusText);
alert(statusText);
return null;
}
}
};
xmlhttp.send(insertClaimXml);
} catch (e) {
alert("callUrl.launchScreen(): Unexpected error: " + e.message);
}

In above code if I make it as true(synchronous) it is executing the event listener(onreadystatechange ) but for false(asynchronous) it is not executing the event listener(onreadystatechange ) and getting exception:

callUrl.launchScreen(): Unexpected error: Failed to execute 'send' on 'XMLHttpRequest': Failed to load "URL".

Show Less
Low-Code App Development Data Integration Java and Activities
Moderation Team has archived post, This thread is closed to future replies. Content and links will no longer be updated. If you have the same/similar Question, please write a new Question.