Rails Ajax Not Working in Firefox - javascript

I have a Rails app that uses an ajax call to (right now) get a JavaScript alert message. It works in Safari and Chrome, but not in Firefox (all current versions). I can step through the code in Firebug and there are no errors raised, yet in the Console section, it lists nothing. Not even an error from the server; nothing. As if Firefox just forgot to do anything about it. Why would this not work?
Here is my code (in CoffeeScript):
jQuery ->
$.ajax
url: "advertisements/grab"
method: "GET"
dataType: "script"

The problem was Adblock Plus. Once I disabled it, then the Ajax was working correctly.

Related

IE11 in Emulation mode IE9 stopping Javascript execution while console is off (no F12)

I have set of Javascript loaded in page and that will be executed onclick of some button . My browser is IE11 latest version and since my application tools doesn't support IE11 I made that change to run application and anything inside it in document emulation mode to IE9 (with "X-UA-Compatible" ) And I have added my domain in compatibility list in IE11.
I am getting a very surprising issue.
All my JS code executes fine if console (F12 developer tools) is keep opened. However it stops executing certain part of JS once console is off in IE11.
Note that, none of my JS code has anything with console.log .
And I have explicitely tried adding below in my JS and it is still not working,
<meta http-equiv="X-UA-Compatible" content="IE=9" />
Can anyone help what could be the possible issue ?
Thanks and appreciate your help.
I am possibly hitting similar issue mentioned below :
Why does JavaScript only work after opening developer tools in IE once?
but below doesn't work for me when I add my code inside head section or body section : so not sure if IE11 this is still a problem and how to resolve this:
<script>
if ( ! window.console ) console = { log: function(){} };
if(!console) {console={}; console.log = function(){};}
</script>
I put the resolution and fix for my issue . Looks like AJAX request that I put inside my javascript was not processing because my page was having some cache problem. if your site or page has a caching problem you will not see that problem in developers/F12 mode. my cached javascript AJAX requests it may not work as expected and cause the execution to break which F12 has no problem at all.
So just added new parameter to make cache false.
$.ajax({
cache: false,
});
Looks like IE specifically needs this to be false so that the AJAX and javascript activity run well.

Aborting/Cancelling an AJAX request not working in IE

I have an application where a user is allowed to upload and download documents. In the download area, the user can select multiple files (all pdf), and do a merge and download.
Great.
There is a modal window that pops up during the merge process, that shows the status of the merge, with a progress bar using SignalR. This works fine across all browsers, and the download happens.
Problem: There is a Cancel Merge and Download button on this modal. It stops the SignalR hub, and sends an abort() request to the AJAX call. This works in Safari, Chrome, and FF - but not IE.
When I look at Fiddler, Chrome stops the server side method in it's tracks. In IE, it tries to send that request to SignalR. The result in IE is that the modal window goes away as expected, but a few seconds later you receive the prompt that the file has been downloaded (actual processing never stops). Note the difference where the abort is called in the Fiddler session below.
Fiddler (Chrome - working):
Fiddler (IE - not working):
Javascript:
$('#cancelDownloadMerge').on('click', function () {
$.connection.hub.stop();
XX.Documents.DocumentsView.download.abort();
XX.Documents.DocumentsView.mergeCancelled = true;
XX.Documents.DocumentsView._isMerging = false;
});
The AJAX call that gets fired when Merge And Download is initially clicked is lengthy and proprietary, however, cache: false and crossDomain: true (since currently running localhost) are set as such, yet the problem still persists. I do not think the AJAX call is so much relevant as this is very much isolated to IE, but I can try and post more if needed.
I suspect this has something to do with the fact that Chrome and FF are using ServerSentEvents whereas IE is using forever frame (SSE not supported).
I'm stuck on this one, any help is greatly appreciated.
The problem was due to the fact that SignalR was always defaulting to using Forever Frame in IE. Adding the below restriction forced SignalR to use Long Polling in IE.
$.connection.hub.start({ transport: ['webSockets', 'serverSentEvents', 'longPolling'] });

Viewing data returned by ajax in IE9

In Internet Explorer 9, how is it possible to view data that is returned by an ajax script?
For example, in Firefox using Firebug, The 'All' tab has a 'Response' Sub Tab. that show any data returned by an Ajax Script like below. How is it possible to view this in Internet Explorer?
I have a script that is failing in IE9. It's not a bug or error, but it just wont work. I've cleared the cache etc. etc.
{"action":"add","close":false,"success":true}
use developer tools or press f12 and in network tab you can see xhr request captured and in then click go to detailed view button to see the response

Symfony2 Web Profiler disappeared ajax calling but invalid response in google chrome only

Im just working on a project with symfony2 and yesterday i started to design it.
Not i just noticed that the web profiler is not visible.
I tried everything! it is active in the config_dev, body tags are opened and closed well. The JS Code is loaded just before </body> and the /_wdt request is called, but heres the response:
now just calling myself this url returns the right response. in this case, the toolbar is shown.
I just tried the same with safari and firefox and everything worked well?! So only it is failing with chrome (even in ikognito mode with no plugin).
so it must have something to do with what? i dunno..
and since this time TinymceBundle not works well also. Even if the js code is loaded my textarea with the .tinymce class is not a Tinymce Textarea, Some Js code errors?
Thanks!
I am using Zend Server CE as Environment. Just stopping and Starting the Server fixed the bug?!

jQuery $.get() function succeeds with 200 but returns no content in Firefox

I'm writing my first bit of jQuery, and I'm having a problem with jQuery.get(). I'm calling this;
$.get(url, updateList);
where updateList is defined like so;
function updateList(data)
{
if (data)
{
$('#contentlist').html(data);
}
else
{
$('#contentlist').html('<li>Nothing found. Try again</li>');
}
}
The function runs, and updateList is called. It works fine in Internet Explorer. However, in Firefox, the data parameter is always empty. I would expect it to be filled with the content of the webpage I passed in as the URL. Am I using it wrong?
Notes;
in Firebug, I've enabled the Net panel, and I get the request showing up. I get a 200 OK. The Headers tab looks fine, while the Response and HTML panels are both empty.
The page I'm trying to download is a straight HTML page -- there's no problem with server code.
The page with JavaScript is local to my machine; the page I'm downloading is hosted on the Internet.
I've tried checking the URL by copy-pasting it from my page into the browser -- it happily returns content.
The error occurs even in Firefox Safe Mode -- hopefully that rules out rogue addins.
You probably won't be able to do this due to cross-domain security. Internet Explorer will allow you to Ajax remote domain when running from file://, but Firefox and Chrome won't.
Try to put both files on the same server and see if it works (it should).
You'll most likely need to fix your page that you're quering with XHR because it should be returning content. Copy paste the link in the Firebug net tab and make a new tab, and edit that page with your text editor so it spits content back.
Stick alert (or breakpoint in Firebug) and see if the data returned is not an object (or if there is any data). If the former - you may need to drill into the object to get your markup

Categories

Resources