简体   繁体   中英

xmlhttprequest on IOS not sending Request?

I am working on a filemaker project. In this project I need to make requests to a soap service. To do so I use a web viewer in Filemaker. From the web viewer I make a soap request and then, using the filemaker fmp:// protocol I can send data from the web viewer to my database for further processing.

To make this work I will load an HTML page into the web viewer. I have the following local html page, containing a script that communicates with the soap service:

<html>
<head>
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Expires" content="0" />
</head>
<body>
<script language='JavaScript' type='text/JavaScript'>
var xhr = new XMLHttpRequest();
var req = ' --- request comes here ----';
xhr.open('POST', 'https://--- soapservice endpoint ---', true, '***_***_***', '******');
xhr.onload = function (e) {
  if (xhr.readyState === 4) {
    if (xhr.status === 200 || xhr.status === 0) {
      alert ('Onload responsetext: ' + xhr.responseText);
    } else {
      alert ('Onload statustext: ' + xhr.statusText);
    }
  }
};


xhr.onerror = function (e) {
  alert ('onerror statustext: ' + xhr.statusText + ',status: ' + xhr.status);
};
xhr.setRequestHeader('Content-Type', 'application/xml');
xhr.setRequestHeader('SOAPAction', '');
xhr.send(req);
</script>
</body>
</html>

When I open this page in Safari, on my Imac, the script works fine and I get a response from the server.

On my Ipad IOS I don't get a response from the server. xhr.Status = 0 and readyState = 4 and responseText is empty. If I put an onreadystatechange function in de script that will alert on every ready state change (1 to 4) I only get alerts from ready state 1 and Ready state 4.

The on error function is triggered giving an alert status 0 and empty status text

Because it is not a public server I cannot post the actual url The username has two "_" in it.

Why is this code not working in IOS ???

The concept is working on IOS, filemaker GO. there is no problem with the javascript code. For some reason the Webviewer in Filemaker is not running the script on Filemaker GO in my main database app. It is running in my test database ???

Found a solution: For some reason the web viewer was not loading the data url on my Ipad. This was fixed by inserting a script step "refresh window". Don't ask me why, but it fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM