The communication with the Exchange server is going with SOAP requests.
When I try to run this code on the mobile device I get a status code of "0".
Any help is appriciated.
Code:
$.ajax(
{
type: "POST",
username:'username',
password: 'password',
url: 'https://outlook.office365.com/EWS/Exchange.asmx',
contentType: "text/xml",
dataType: "xml",
data: soapRequest,
success: function(data)
{
hyper.log(data);
},
error: function(jqXHR, ajaxOptions, thrownError)
{
hyper.log('error status: ' + jqXHR.status + ' errorTrown: '+ thrownError);
}
});
Connecting from Cordova to EWS with jQuery did not work out for me. But i found a work arround wich might be usefull for some other people.
As an alternative I build a PHP webservice that handled al the communication with EWS.I didn't use the EWS-php class.
Cordova then called the webservice via jQuery.
I am now able to get and adjust calender events etc.
have you looked at https://stackoverflow.com/a/39152138/5884960 I recently did modify the original library to work with cordova. new npm package is ews-js-api-browser
Related
There is a server which provides a XML under a certain URL (for example: https://myxmlfile). For this server request is a p12 certificate with password needed which I installed in Firefox and on my machine. If I enter the URL in the webbrowser (https://myxmlfile), the xml will be shown.
Now I try to make a jQuery GET Request from my website (which is just running on my local machine at the moment). In that GET Request I want to get the same XML, but this doesn't work and I get SSL_ERROR_HANDSHAKE_FAILURE_ALERT.
I'm pretty new to certificates. So is it not enough to install the certificate in the browser? Do I have to send the certificate in the GET request or something like that?
This is the request:
$.ajax({
type: "GET",
url: 'https://myxmlfile',
data: 'subscriptionID=0011',
dataType: "xml" ,
async: false,
error: function(xhr, status, error){
console.log('Error: '+ xhr.status+ ' - '+ error);
console.log("error");
},
success: function(xml) {
console.log(xml);
}
});
Thanks for your help.
I have a web application that uses jQuery ajax to get some data. In this site I also have a Logger that reports to me when an error happens.
Very frequently I get this error on ajax calls:
{"readyState":0,"responseText":"","status":0,"statusText":"error"}
The problem is that this error is randomly and I'm not able to reproduce it. I get this for all ajax scripts. The request is made on same origin and at the server I've defined "Access-Control-Allow-Origin", "*".
All browsers get this error:
Safari 9
Chrome
Internet explore 11
etc...
The jQuery ajax code:
$.ajax({
url: 'MyUrl',
type: 'POST',
dataType: "json",
data: {dataVars},
error: function(response, ajaxOptions, thrownError) {
log.error( 'StringError: ' + ajaxOptions + '\n\nthrownError: ' + JSON.stringify(thrownError) + '\n\nResponse: ' + JSON.stringify(response));
},
success: function(res){
}
});
The request is performed to a servlet. What could be the problem?
From W3schools:
readyState=0
Means that the request isn't sent. (your broswer isn't connected to the targeted server).
It's mean that the socket is not opened : no TCP handshake, so the targeted URL is just not reached...
So check the validity of myUrl (is it a good domain? no cross-origin), and also connectivity of the client (proxy? if myUrl is secured / use an other port, maybe it is just not opened...)
I think the issue might be on server side, if it is random. but especially for myUrl, if you can get the web page anyway...
But the error is strange, if it comes from the same server!
Anyway, I think it is because the connection between your client and the targeted server is unstable, so maybe you can try to inscrease the timeout of the request, or retry it on error (example with recursive loop):
var remainingRetry = 3; //or something else
function handleRequest()
{
$.ajax({
url: 'MyUrl',
type: 'POST',
dataType: "json",
data: {dataVars},
error: function(response, ajaxOptions, thrownError) {
if (remainingRetry)
{
remainingRetry--;
setTimeout(handleRequest, 1000); //timeout between two tries
}
else log.error( 'StringError: ' + ajaxOptions + '\n\nthrownError: ' + JSON.stringify(thrownError) + '\n\nResponse: ' + JSON.stringify(response));
},
success: function(res){
}
});
}
I had the same issue before and in my case the problem was
that other js function redirecting to another page before my first request has a chance to complete which is practically canceling or killing my request
some thing like
function redirectToAnotherPageFn () {
window.location = "/otherpage.html";
};
I found a script for real chat using $.ajax jQuery, but it refereshes only my massages. For example:
I write to You: Hello, this message refresh for me.
You write to me: Hey, to see your message I must refresh a site by clicking F5, but You do not have to click F5. Something wrong!
My $.ajax code:
$(document).ready(function() {
$("#lupnijto").click(function (e) {
$("#lupnijto").hide();
$("#LoadingImage").show();
var zeszyt_value = 'zeszyt='+ $("#contentText").val(); //build a post data structure
jQuery.ajax ({
type: "POST",
url: "response.php",
dataType: "text",
data: zeszyt_value,
cache: false,
success: function(response) {
$("#responds").prepend(response);
$("#contentText").val('');
$('#contentText').focus();
$("#lupnijto").show();
$("#LoadingImage").hide();
},
error:function (xhr, ajaxOptions, thrownError) {
$("#lupnijto").show();
$("#LoadingImage").hide();
alert(thrownError);
}
});
});
});
What am I doing wrong? Why data only refreshes for me? How the chat works? Am I doing it correct? I accept answers. Thanks.
For such real time applications, you need to use WebSockets: On MDN
,you can also check on some WebSockets API Socketio for Node.js
I do advice those, but also you can use AJAX (not recommended).
You can use Socket.IO. For non-WebSockets browsers you can use Engine.IO.
I have an eye tracker (mirametrix) running as a server in localhost. In order to capture data from this I should send a xml request as given below;
SEND:<GET ID="TIME_TICK_FREQUENCY" />
I have a web-app running as the client and I need to make a request to this server through that. I wrote the following code but it doesn't seem to send the request properly to the server.
var request = $.ajax({
url: "http://127.0.0.1:4242",
type: "GET",
dataType: "xml",
data: {
data:'<GET ID="TIME_TICK_FREQUENCY" />'
},
});
Can someone please help me with this ?
Thanks in advance
$.ajax({
url: ajaxurl,
data: "<root><blah><blah></root>",
type: 'POST',
contentType: "text/xml",
dataType: "text",
success : parse,
error : function (xhr, ajaxOptions, thrownError){
console.log(xhr.status);
console.log(thrownError);
}
});
I think you need to post it.
this is not plain javascript.. looks more like jquery.. also what do you mean with 'properly'. It's kind sending it, but not really? Aside from that, I see the following problems
The url is wrong, and although your browser may handle it, your url should end with a slash.
Your xml is invalid. Needs to start with <?xml version="1.0"?>.
If you accessed this script through a different host than 127.0.0.1., or if the script is running on a different port than 4242, this will not work without CORS headers on the server.
I am very new to the phonegap platform, and i am on research about the issue below for the last two weeks.
I am working on a PhoneGap project for android which communicates with a remote https server(SAP j2ee server). I dont have any controll over server. The server gives data as SOAP response only in a secured way.
Now my problem is that i am not able to send a request from my application to the server. When i send a request i get either HTTP Status 'error' or a success message without any data.
Is there any alternative methods available for the same issue for android and blackberry?
Please go through the code below and please help me.
function soapRequest(){
$.mobile.showPageLoadingMsg();
var username=$("#username").val();
var password=$("#password").val();
var SOAP_Login='<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:OrSVi"><soapenv:Header/><soapenv:Body><urn:getP><urn:userName>'+username+'</urn:userName></urn:getP></soapenv:Body></soapenv:Envelope>';
$.ajax({
url: URL_Login,
type: "POST",
dataType: "xml",
async:false,
cache: false,
crossDomain:true,
data: SOAP_Login,
complete: endSaveProduct,
beforeSend: function (xhr) {
xhr.setRequestHeader("SOAPTarget", "https://ex.example.com:443/OrSvi/Config1?style=document");
xhr.setRequestHeader ("Authorization", "Basic WFWeMjEyMDerebWrteTyyku==");
xhr.setRequestHeader("SOAPAction","urn:OrSviWsd/OrSVi_Document/getPRequest");
},
contentType: "text/xml;charset=UTF-8"
});
}