What could be stopping AJAX from returning? - javascript

I'm trying to troubleshoot a problem on a client's machine for our website. We're using an ajax call to get information on a page to select additional parameters. Our callback function has a block of code for reading when the ajax coming back is an error or is correct. For every other computer that we've tested this with, the ajax comes back. However, for a particular client, we're seeing the ajax come back with the error message, meaning the response never got there successfully or that it's corrupted or broken.
Does anyone know how this would happen? The client is using IE 8 and I've tested IE 8, IE 9, IE 10, and Chrome and all of those work on my computers.
EDIT: As of now, we don't have access to the system and the network that would be causing the error. They are trying to see if they can accept everything from our domain and see if that fixes it, but right now, I can't put Fiddler on their computer.

I've seen any amount of random behaviour caused by virus scanners and so-called network security products. Try adding an exception for your site to any security software your client is running.
The other thing to do is to use Wireshark, Fiddler, etc. to see what's actually happening at the network level.

Related

Delphi TWebBrowser JavaScript Errors and Cookies

I have been stuck on this for a couple of weeks now and this is a follow on from SO question Delphi REST Debugger Returns Error 429 Too Many Requests but Browser Returns JSON as Expected
I was wanting to get the content of a url response using the TNetHTTPRequest and TNetHTTPClient components. I was continually getting 429 errors “too many requests”. When using Firefox Inspect Element to look at network and storage, I discovered that I needed to receive cookies and then send those cookies with my request. Unfortunately, one of the cookies essential to the website content seems to be dependent (I think) on the execution of javascript. I went back to first principles and dropped a TWebbrowser on a form (VCL) and sure enough browser shows a javascript error “Expected Identifier”.
When I use the TWebbrowser in FMX it does not throw an error it just does not return the website contents at all and remains blank. I need FMX as I will be in a cross platform mobile environment.
The URL is https://shop.coles.com.au/a/national/home
I use Delphi Community Edition 10.3.3 Rio.
The URL returns perfectly in commercial browsers Firefox, Safari, Chrome and even CEF4Delphi. Unfortunately, I can’t use CEF as I need cross platform.
I would like to know how to get the website content returned to the browser (or even better NetHTTPClient) without script errors and how to access the browsers current cookies.
Any help will be most appreciated.
Thanks,
John.
URL returns perfectly in commercial browsers ... without script errors and how to access the browsers current cookies
If you'd inspect the network traffic (F12 > Network, then requesting your URL) or use uMatrix (to block everything that doesn't belong to the domain by default) you'd see the JS does at least one XHR to amazonaws.com. Your HTTP transfer alone (as done by TNetHTTP*) works fine and you get the same resource that each internet browser gets.
However, you don't operate with what you got (in contrast to the internet browser, which also automatically parses the HTML, sees JS resources, and executes them). TWebbrowser does not what you take for granted most likely due to security settings (try to get an error console in there, preferably F12 again). You need to do the same: parse the HTML resource for JS URIs, requesting those and executing what you get, while still providing the same cookie environment.
For executing JS you could use Chakra or mORMot or BESEN. It's challenging at first, but the more you understand about HTTP (including cookies) and a JS engine, the more you'll see why "things work" in one situation and not in another. There's a reason why an internet browser is a very complex software and not just a downloader.
As per this forcing IE11 Quirks mode might cure your problem already when using TWebBrowser:
TBrowserEmulationAdjuster.SetBrowserEmulationDWORD(TBrowserEmulationAdjuster.IE11_Quirks);

status code 12004 while doing a service call

I am doing a service call in my javascript which return xml data using xmlHttpRequest.My service call is working in chrome and firefox perfectly and getting the data(it is a https call).But when i try the same with IE11 it is giving status code 12004 .I tried searching it on google i found only one answer saying it means ERROR_INTERNET_INTERNAL_ERROR.
I tried opening fiddler to see the request but when i open up fiddler service call is working fine,but when i close fiddler it is showing same error code.
From the WinINET constant ERROR_INTERNET_INTERNAL_ERROR it appears that the issue is related to the WinINET API which I assume is being used by IE to enable itself to interact with HTTP protocols (including HTTPS) to access Internet resources
http://msdn.microsoft.com/en-us/library/windows/desktop/aa385465(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/windows/desktop/aa383630(v=vs.85).aspx
If you really wanted to go deeper and understand the issue, try to download STRACE which is socket/SSL tracer designed to generate LOG for Internet Explorer:
http://www.microsoft.com/en-us/download/details.aspx?id=7643
On a quicker check, you might want to see if your Windows updates is up-to-date to make sure your wininet.dll is the latest and greatest

Possible causes for long blocking xhr on mac chrome?

I have a consistent extremely long (2min+) blocking call on mac/chrome. The same set of steps work just fine on other operating systems or browsers. (And even some other macs.) The site isn't super chatty, and there aren't any other requests that take anywhere over 2 seconds.
The blocking PUT call almost always follows a DELETE call to a different url. (Same server.) According to my console logs, the server actually receives and returns the results of the PUT call very quickly. So Chrome thinks it is blocked but it is actually already processed!
Any ideas?
Following up on this post: Chrome and Firefox CORS AJAX calls get aborted on some Mac machines
This mac had a DISABLED Sophos antivirus on the machine. Uninstalling it completely fixed this issue.
ARGGGGG.
Hopefully someone else finds this post and is able to spend less than the hours we spent on it.

Internet Explorer stuttering requests

For a special project I chose to write my very own tiny web server which is actually quite easy with the .Net Framework (HttpListener class).
Everything was working beautifully until yesterday when I started to test with Internet Explorer.
My server kept crashing on any ie request ! I finally managed to figure the reason out : ie litterally stutters ! (well at least ie7 and ie8, I've not tried other versions yet).
The problem never occurs with FireFox nor Chrome nor Opera.
To be more specific, I'm using dynamic javascript insertion in the web page to get around the same origin policy in a cross-domain call scenario. This script generates a request to my tiny server. Let's say the request built is :
http://localhost:8081/myService?p1=A,p2=B,p3=C,p4=D,p5=E
With FFox, Chrome or Opera, my server indeed receives a single request from the browser :
http://localhost:8081/myService?p1=A,p2=B,p3=C,p4=D,p5=E
with ie, my server receives a random amount of partial requests like :
http://localhost:8081/myService?p1=A,
http://localhost:8081/myService?p1=A,p2=B,
http://localhost:8081/myService?p1=A,p2=B,p3=C,
http://localhost:8081/myService?p1=A,p2=B,p3=C,p4=D,
(and in fact a lot of them since I have 20 parameters or so...)
and finally :
http://localhost:8081/myService?p1=A,p2=B,p3=C,p4=D,p5=E
This is bascically not big deal as my logic is able to handle the lacking parameters situation. The problem is that each incomplete request actually closes the connection (error 1229). That was crashing the server which was trying to answer to each request. The fix was easy but I still don't like the fact that the server is flooded with those intermediate "unanswerable" and thus unuseful requests.
(Moreover, the request sometimes looks like :
http://localhost:8081/myService?p1=A,p2=B,p3=C,?p1=A,p2=B,p3=C,p4=D,p5=E
!!! )
I traced the javascript : the generation function is called only once (whatever browser) so this really sounds like an ie issue.
Does anyone have an idea to prevent this behaviour from ie ?

Very strange JavaScript error in IE7

I am developing JavaScript chat. I have done the prototype, and it seems to work pretty well. But our client says that it doesn't work. We both use IE7 on PC, and try to run the same JavaScript code. I have no idea about the reason.
On my client's machine there is "object is expected" error. I have thought about security restrictions, and tried to make security level higher in my IE, but in this case the script doesn't run and there is no error messages. I am running the script on the remote server.
Clients machine may be running within a group policy which for security reasons can restrict execution of scripts. Hence the client may need to include your prototype as part of their trusted sites and relax restrictions on trusted sites
Are you able to provide any more details about the specific error? Are you sending the client a zipped up version of the solution or is it hosted somewhere?
From the IEBlog; you could try using the Microsoft Script Debugger (see post)
One thing you may find, especially with IE is the error that is reported is actually caused by a previous error in the code.
Try running your javascript through jslint to ensure that it is well formed.
In Firefox with [firebug], enable strict warnings in the console.
Related SO posts.
debugging-javascript-in-ie7.
debugging-javascript-for-ie6.
Edit::
One thing to look for is comma's after the last element in an array, IE seems to ignore the closing brace } and keep adding following code to the array. Firefox gracefully just assumes that you forgot it.
If you're running the code from localhost and he's running it from a remote server then it could be a timing issue - some script could be running before the page has finished loading that's causing a problem on a slow connection that is hidden on a fast connection.
You can get this error if you try to use an exernal script file that the client's browser can not access.
Example :
<script src="http://localhost/scripts/freelib.js" language=Javascript> </script>
You can access freelib.js on your machine, but running it from any other machine it wouldn't work.
Are you sure all the scripts are being loaded? I've seen that error message before when some or all aren't loaded (maybe they didn't get deployed). Try manually copying the addresses of all the js files from the source and pasting them into the address bar to make sure that the browser can actually access them.
Can you run the page on your client's machine in Firefox? The firefox console should give you a more detailed error message than IE will.

Categories