Edge Browser Ajax file upload call WebApi is not working - javascript

Edge Browser Issue : Ajax Call to web API is not working in Edge browser, rest other browsers its working fine including IE.
function uploadPDFajaxcall(data, url) {
$.support.cors = true;
$.ajax({
url: url,
type: 'POST',
data: data,
cache: false,
dataType: 'json',
processData: false,
crossDomain: true,
//contentType: "application/json",
contentType: false,
success: function (data, textStatus, jqXHR) {
},
error: function (jqXHR, textStatus, errorThrown) {
console.log('ERRORS: ' + textStatus);
}
});
}
Actual: Edge browser getting Error (catch). rest all browsers working as expected.
Expected: It should hit the web API successfully

Related

Cordova Ajax call throwing net::ERR_SPDY_PROTOCOL_ERROR

I have two Ajax calls but one of the Ajax calls are returning net::ERR_SPDY_PROTOCOL_ERROR.
The Ajax call urls are coming from WordPress Woocommerce RestApi.
When I run chrome in mode - chrome.exe --user-data-dir="C:/Chrome dev session" --disable-web-security - the error disappears and everything is working correctly.
Error
Ajax call that is not working:
$.ajax({
url: "https://krii.000webhostapp.com/wp-json/wc/v2/products/categories?per_page=99",
success: function(json){
console.log("Success", json);
$.each(json, function (index, categories) {
//console.log(categories);
catego.push({Cat_Name: categories.name});
//console.log(catego);
$('select#categories2').append('<option data-id="> categories.id">'+categories.name+'</option>');
});
},
error: function (XMLHttpRequest, textStatus, errorThrown){
console.log(textStatus,errorThrown)
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('ck_...:cs_...'));
},
type: 'GET',
contentType: 'json'
});
Ajax call that is working:
$.ajax({
url: "https://..../wp-json/wc/v2/products/categories?per_page=99",
success: function(json){
console.log("Success", json);
$.each(json, function (index, categories) {
//console.log(categories);
catego.push({Cat_Name: categories.name});
//console.log(catego);
$('select#categories').append('<option data-id="> categories.id">'+categories.name+'</option>');
});
},
error: function (XMLHttpRequest, textStatus, errorThrown){
console.log(textStatus,errorThrown)
},
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic ' + btoa('ck_...:cs_...'));
},
type: 'GET',
contentType: 'json'
});
How exactly I can fix this, cause it does not work on mobile device.
This error ERR_SPDY_PROTOCOL_ERROR is found in Google chrome. With latest updates of google chrome it is depracted. This protocol was added for faster web load and security. You can learn more from how-to-fix-err_spdy_protocol_error-in-google-chrome-2019

getting data but unable to save it ajax

This is my code for a service
function usersClicked() {
var response;
$.ajax({
url: 'somedomain.com/get_users',
type: 'GET',
dataType: 'jsonp',
crossDomain: true,
contentType: "application/json; charset=utf-8",
success: function (data, status, xhr) {
alert(data);
}
});
}
In network tab, I am able to see the response but it is unable to alert data. No dialog is being shown. can anyone help me with this
Response Header

Calling web service from code behind instead of javascript

I have a javascript code that calls a web service from another server, it's working, but i need to call it from code behind due to an http call request issue, following my code :
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "http://10.8.111.12:7181/CatchEventLink.asmx/CollectDataLink",
data: JSON.stringify({ "pDataDictionnary": lDataCollected }),
dataType: "json",
async: true,
success: function (data, textStatus) {
if (textStatus == "success") {
//alert('success');
}
},
error: function (exception) {
//alert('Exeption : ' + exception);
}
});
Any suggestions please??

ajax request not working in google chrome - net::ERR_INCOMPLETE_CHUNKED_ENCODING

I have a plain html page and I write some javascript code that use jquery ajax request. The ajax request sends to server successfully in firefox and IE, but does not work in google chrome! When the ajax request sent, chrome console shows net::ERR_INCOMPLETE_CHUNKED_ENCODING error. I don't know How can I solve this strange problem. Here is my ajax code:
var data = {};
data['type'] = "email";
data['value'] = "test#gmail.com"
$.ajax({
headers: {
Accept: "application/json; charset=utf-8",
"Content-Type": "application/json; charset=utf-8"
},
type: "POST",
url: "/testUrl",
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function(result) {
alert("success");
},
error: function(data) {
alert("error");
},
failure: function(errMsg) {
alert("failure");
}
});
I tested plain ajax request with XMLHttpRequest javascript object, but also has above problem.

Ajax error value return null

I have a function in ajax :
$.ajax({
type: "POST",
url: "#Url.Action("FiltraLevatamento", "Consulta")",
data: JSON.stringify(jsn),
contentType: "application/json",
dataType: "json",
async: true,
success: function (data) {
result(data);
$("#modalboxProcessa").modal("hide");
},
error: function (XMLHttpRequest, txtStatus, errorThrown) {
$("#modalboxProcessa").modal("hide");
$("#modalboxErro2").modal("show");
}
});
In my local machine works properly only when I publish in the server error in ajax .
Can anyone tell me what is the problem ? I have pretty much the same ajax only returning me other than data, and is running fine .

Categories