简体   繁体   中英

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

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