Click here to Skip to main content
15,887,340 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
After executing my rest api I am getting call back to error with a textstatus 'parsererror'.(Sometimes only it shows parsererror)

I am using an iframe in window and imitate the ajax request from there.(IE shows the parser error but chrome works fine).

please see my below request.


return $.ajax({
               type: 'GET',
               async: true,
               contentType: 'application/json; charset=utf-8',
               url: this.serviceUrl + 'Documents?contextType=' + this.currentContextType + "&contextUid=" + this.currentContextUuid + "&dataSource=" + this.currentContextDataSource,
               error: (jqXHR, textStatus, errorThrown) => {
                   if (jqXHR.status == 502 || !navigator.onLine) {
                       Common.Utils.connectionLost();
                   }
                   else if (textStatus === "parsererror") {
                       try {
                           throw new Error('textStatus:parsererror');
                       }
                       catch (e) {
                           console.log(e);
                       }
                   }
                   else if (jqXHR.status == 500 && jqXHR.responseText) {
                       WorkflowUI.Handlers.ErrorHandler.HandleErrorServiceLevel(JSON.parse(jqXHR.responseText));
                   }
               },
               success: (response) => {
                   this.tableData = response;
                   this.populateTable();
                   if (this.currentWidgetPosition.toLocaleLowerCase() === "left") {
                       setTimeout(function () {
                           parent.WorkflowUI.PowerJacketSingleton.showScannerWidget(this.currentContextUuid, this.currentContextDataSource);
                       }, 0);
                   }
               }
           });


What I have tried:

i have tried by POST and tried by catch the exception in error to avoid jquery object not supported error


Any way to suppress this error without showing jquery error.

Any answer is appreciated.
Posted
Updated 17-Jul-17 12:00pm
v3
Comments
Afzaal Ahmad Zeeshan 14-Jul-17 18:21pm    
Parser error is nothing that depends on time; but on the content. What content is returned, please check that.
shefeekcm 14-Jul-17 18:29pm    
textStatus is parse error.

but response is 200.

The expcted result is an empty json with staus 200.

Fiddler shows that but the server response comes at error area of ajax.

This is comes sometimes, not always.
shefeekcm 14-Jul-17 18:32pm    
In every place the call comes success without any issue.

In this area the call is initiated from an iframe and in IE sometimes the error comes.

but in chrome it works well.

Anyway to suppress this error?
shefeekcm 14-Jul-17 18:35pm    
The final error comes from UI is in jquery makearray method.

Object is undefined. Its comes because the array element has parse error string value.


makeArray: function (n, t) {
var r = t || [];
return n != null && (ii(Object(n)) ? i.merge(r, typeof n == "string" ? [n] : n) : ni.call(r, n)), r;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900