0

JB Nizet, thank you! The problem is not the Adblock, but Firefox browser. I have changed the title and problem description. What could be a reason for an error for a simple Angular 2 call in Firefox? return this.http.get(this.APIGetPrice + zipcode) .toPromise() .then(this.extractData) .catch(this.handleError);

My page with the problem: http://www.asbuiltsolutions.com/AsbuiltQuotes.html?p=1 enter 415 and click Next Step.

There are no problems in IE and Chrome. The screen for Chrome debug:

enter image description here

The debug point is in the app.services.js, function is APIRequestService.prototype.getPrice Next step is: APIRequestService.prototype.extractData and I have all data I need.enter image description here

But Firefox returns me a complicate stack trace I am not able to debug: enter image description here

Can somebody help me with Firefox debug to spot the problem? Thank you.

Elena Orel
  • 71
  • 5
  • 1
    Doing that in Firefox descktop, with the console opened, reveals that an exception is being thrown in JSON.parse(). So it doesn't seem to be a problem with the browser, but rather with your code: the backend returns XML, and it's parsed as JSON. – JB Nizet Nov 02 '16 at 20:11
  • My console is pristine. I don't see the JSON.parse() error. Unfortunately, cannot attach images, but the links are: primeedge.com/asbuiltsolutions1.jpg and primeedge.com/asbuiltsolutions2.jpg I have no complains with desktop browsers. But can you send me the screen when you see the console error? – Elena Orel Nov 02 '16 at 20:51
  • oh, I see it in Firefox.. checking. thank you for your hint. – Elena Orel Nov 02 '16 at 22:29
  • I posted the updates - still no clue what is going on in Firefox. – Elena Orel Nov 03 '16 at 00:54

1 Answers1

0

Guys from github gave me a hint where I should look for the problem: https://github.com/angular/angular/issues/12695

"So what I can see is that FFox is sending different Accept headers (text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8) vs. / in Chrome."

I accepted all headers in my typescript file private headers = new Headers({ 'Content-Type': '/' }); and restricted xml type in my WebApiConfig file as: var appXmlType = config.Formatters.XmlFormatter.SupportedMediaTypes.FirstOrDefault(t => t.MediaType == "application/xml"); config.Formatters.XmlFormatter.SupportedMediaTypes.Remove(appXmlType);

(How do I get ASP.NET Web API to return JSON instead of XML using Chrome?)

Community
  • 1
  • 1
Elena Orel
  • 71
  • 5