-1

In our web application we want to trigger a locally run widget using xhttp request, in Chrome and firefox, this is working fine and the requests are being received but in MS browsers (Edge and IE11) it wort fire and I get an error returned to the variable,

The request line is;

var screenRecorder = $.get('http://127.0.0.1:9645/widget?command=connect&agent=amtest&password=amtest');

where agentName and password are taken from JS variables

[object,object]  {readystate:1}

I am relying on the correct response being received to flag if the widget is running to allow further communication requests to it.

I am hosting the app on IIS6.1 and have enabled CORS but this still isn't helping with IE and Edge. Can anyone advise how I can resolve this?

The IE console shows the following error:

XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd.

KenD
  • 5,280
  • 7
  • 48
  • 85
  • 1
    So what's the error ? – adeneo Sep 12 '17 at 15:02
  • The error is that the xhttp request is being blocked by IE and Edge - even though CORS is fixed, this results in me not getting the correct output to the variable – Allan Macritchie Sep 12 '17 at 15:04
  • 1
    So the console in Edge says that ... *"we've blocked this!"* etc – adeneo Sep 12 '17 at 15:05
  • No - it was previously showing an error of; XMLHttpRequest cannot load http://127.0.0.1:9645/widget?command=connect&agent=amtest&password=amtest. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '[domain]' then I ensured that CORS was corrected at both server side and engine side - now there is no error being reported - I know the message isn't being sent as the widget write all received requests to console and I see them when using chrome and IE – Allan Macritchie Sep 12 '17 at 15:07
  • 1
    Add some handlers, and see what happens -> https://jsfiddle.net/ofL48y5b/ – adeneo Sep 12 '17 at 15:11
  • I tried adding success and complete but they trigger incorrectly – Allan Macritchie Sep 12 '17 at 15:12
  • I've added the handler and see the fail output - IE also shows error XMLHttpRequest: Network Error 0x2efd, Could not complete the operation due to error 00002efd. – Allan Macritchie Sep 12 '17 at 15:18
  • 1
    https://stackoverflow.com/questions/14527387/script7002-xmlhttprequest-network-error-0x2ef3-could-not-complete-the-operati there's various causes of this. – Kevin B Sep 12 '17 at 15:24
  • 1
    And now you have something to search for, and Kevin already did it for you ^ – adeneo Sep 12 '17 at 15:26
  • I was reading this exact page when I got the alert for Kevins reply, will read through and see if I can get to the route – Allan Macritchie Sep 12 '17 at 15:36
  • thanks @KevinB, I added a call to first initiate an http connection to local host as outlined in https://stackoverflow.com/questions/14527387/script7002-xmlhttprequest-network-error-0x2ef3-could-not-complete-the-operati and this resolved the issue – Allan Macritchie Sep 13 '17 at 13:37

1 Answers1

0

The fix for this issue is to initiate a connection before sending the request using the following code before sending the initial and subsequent $.get requests;

 var screenRec = new XMLHttpRequest('http://127.0.0.1:9645/widget');

This forces IE and Egde to open the connection as without it the $.get request will not be sent.