I want to know the time taken for the font to be downloaded while using font-face. Hence i am using the following code
$.ajax({
async: true,
type:'GET',
url: "fontPath/font.woff",
CustomData: {fontObjIndex: i}
success: function() {
console.log('font downloaded')}
});
so that i can confirm that a particular font has been downloaded in client side using font-face.
This method works well in all modern browsers except IE 9. Does $.ajax accept Font urls in IE 9?
Note: It didn't enter progress or fail functions either.
Edit : Sorry i entered the code wrongly there. The error is not in that line as it works in all other browsers and it still persists in IE9
Try this:
$.ajax({
async: true,
type:'GET',
url: 'fontPath/font.woff',
CustomData: {fontObjIndex: i}
success: function() {
console.log('font downloaded')}
});
Please apply the following code to work
$.ajax({
async: true,
type:'GET',
url: "fontPath/font.woff",
CustomData: {fontObjIndex: i},
success: function() {
console.log('font downloaded')}
});
IE has no console object when Developer tools is not open.. Try running your code by commenting your console.log and try again..
If you want to use console , you need to define that first if Developer tool's is not open..
if (typeof console === "undefined" || typeof console.log === "undefined") {
console = {};
REF : Jquery AJAX not working in IE9
Related
I'm trying to debug problems in a javascript file. When I make a change to the file and start the Visual Studio Debugger (F5) a [dynamic] version of the javascript file shows up in the debugger and stops at my break point, but the change I made to the file is not reflected in the [dynamic] version. For example, here is the function in the javascript file:
function GetJobNotes(ScheduleID) {
var par = "ScheduleID='" + ScheduleID + "'";
$.ajax({
type: "Post",
url: "MaskingScheduleService.asmx/HelloWorld",
//data: par,
dataType: "xml",
//success: GetInfoSuccess,
//error: ProcessError
});
alert("ajax called");
}
and here is what shows up in the [dynamic] version of the file when debugging:
function GetJobNotes(ScheduleID) {
var par = "ScheduleID='" + ScheduleID + "'";
$.ajax({
type: "Post",
url: "services/MaskingSchedule.asmx/GetJobNotes",
data: par,
dataType: "xml",
success: GetInfoSuccess,
error: ProcessError
});
}
How do I get the [dynamic] version to match the code in my javascript file?
The issue is that there is an option in Chrome that breaks the updated js file. With that option, Chrome will block the changed js content and always use the previous js content.
Solution
When starting vs debugging under Chrome, please press F12 and then select Network menu.
This is an option called Disable cache
Check this option and then refresh your web page and it will load the latest version of the javascript file.
I have a js function
function getdata(gender,filtervals,limit) {
//alert("Hi");
$(".photo,.info").html('...Loading....');
jQuery.ajax({
type: "POST",
url: 'data.php',
data: {
filtervals : filtervals,
gender : gender, // This is where the error is mentioned
limit : limit
},
success: function(result) {
if(result){
$("#List").html(result);
$("#List").css('display','block');
}
}
});
}
I get an error in IE (Only in IE) console saying 'expected ":"' at line 169 which I have identified with by commenting that on the right side
This code works well on chrome and firefox but not on IE and some mobile browsers.
Been trying to narrow down why my entire javascript is not working on IE and some mobile browsers. After vetting my code through JsHint and other tools, I checked on IE console. And this seems to be the only problem.
Any help would be greatly appreciated as I have been breaking my head on thsi for a long time.
My AJAX Call is working fine in all browsers including IE 8,9,10,11 in my Windows 8 machine
But the same code is not working in my friend's machine who has windows 7 and IE 11 installed. Though the same code is working on his other browsers i.e. Firfox, Chrome etc.
My AJAX call is as below
str = "type=checkloginstatus";
$.ajax({
type: "POST",
dataType: "json",
url: "random.php?"+$.now(),
cache : false,
data: str
}).done(function( data ) {
console.log(data);
});
Can anyone help me please ?
Thanks in advance !
I have same problem. Windows 7 and IE 11 is a bad combination. When I run my AJAX (called ajaxB.asp from the url line in IE11 it returns data. However if I run it from within my html page it returns NOTHING!
Code:
function winkeltonen(dm)
{
$.get(
"ajax/ajaxB.asp",
{stand: dm},
function (data) {
if (data == '...') // empty
{
$('#DYNdeel2').hide();
}
else
{
document.getElementById('DYNbal').innerHTML = data;
$('#DYNdeel2').show();
}
});
}
It runs fine in opera and Firefox and all IE's before 11
I am developing a website which loads html from a template page then loads content from XML. for instance these are called in the document.ready function
$.ajax({
type : "GET",
url : "template.html",
dataType : "html",
success : function(html) {
var ndoc = document.createElement('html');
ndoc.innerHTML = html;
page = $('body', ndoc);
$('body').html(page.html());
$.ajax({
type : "GET",
url : "XML/content.xml",
dataType : "xml",
success : function(xml) {
page = $(xml).find('chisiamo').find('dialogue')[0];
setupPage(page);
}
});
}
});
This works well in Firefox and Safari. But in Chrome i get a 'Origin null is not allowed by Access-Control-Allow-Origin' when it tries to load template.html. How can I solve this problem? thank you very much.
Try to start Google Chrome with this arguments :
google-chrome --disable-web-security --allow-file-access-from-files
You should be able to create a Chrome Web App and set the permissions in the manifest to allow it access to read files from the file:// scheme.
http://code.google.com/chrome/extensions/manifest.html
You have to add permissions to the page you are requesting in the manifest. Also try using $.getJSON instead ;)
I have a onclick event in JavaScript that I have chosen to format as below:
<a href="" onclick = "
$('.white_content').html('<img src=\'/making.gif\'>');
$.ajax({
url: '/show_album.php?id=<?=$album['id']?>',
type: 'GET',
success: function(data){
$('.white_content').html(data);
},
error: function(){
alert('failed');
}
});
return false;">
In FireFox, this is fine, but in Internet Explorer 8 the script is crashing because of the way I have layed out the code in new lines instead the onclick attribute.
Does anyone know a good way to fix this? I am still developing this page and others using similar code and I would like to keep a clean layout as opposed to all on one line.
If I inspect the onclick attribute in Internet Explorer developer tools I find each line seperated by several strange boxes that I assume represent unknown characters, obviously in IE, this is causing the error.
do the following instead:
<script>
function myOnclick() {
$('.white_content').html('<img src=\'/making.gif\'>');
$.ajax({
url: '/show_album.php?id=<?=$album['id']?>',
type: 'GET',
success: function(data){
$('.white_content').html(data);
},
error: function(){
alert('failed');
}
});
return false;
}
</script>
<a href="" onclick="return myOnclick();">