While testing my jQuery script in IE 9 it shows error in jquery-1.6.2.js --
SCRIPT5022: Exception thrown and not caught
jquery-1.6.2.js, line 548 character 3
My js file used to work with no problems in other browsers - firefox 3.6, 5.0, opera 11, chromium, chrome. I do not understand. Is there a bug in the jquery source or is there a bug in my js file ? How do I find it ?
It hasen't been long since I started in this area so please I would really appreciate some ideas.
Thank you in advance.
[edited]
I've added the complete code.
I've learnt from :
http://net.tutsplus.com/tutorials/javascript-ajax/how-to-create-a-jquery-image-cropping-plug-in-from-scratch-part-ii/
I don't know which part to add. The whole code does not fit in stackoverflow's submit. says "body is limited to 3000 characters; you entered 42121 "
[2nd edit]
I have used 'error' in my ajax submit.
//jquery ajax submit for resizing
function submit(myform,e){
$n.val($image.attr('src').replace(/^[^,]*\//,''));
var mydata = myform.serialize();
$.ajax({
url: $myform.attr('action'),
cache: false,
type:$myform.attr('method'),
data: mydata,
success: function(response){
var img = $("<img />").attr('src', 'images/'+response+'?'+ e.timeStamp) //<-- img name here
.load(function() {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
alert('Incorrect image.');
} else {
$("#result").html(img); //<-- put cropped img here.
}
});
},
error: function(){ //<-- error used here
$('#result').html("Err. Loading Image");
}
});
};
I traced out my problem. IE prevented changing of attribute which let to the jQuery error.
Note: jQuery prohibits changing the type attribute on an or element and
will throw an error in all browsers. This is because the type attribute
cannot be changed in Internet Explorer."
from http://api.jquery.com/attr, just after 1st warning notice.
So I changed my code from earlier
$('input').clone()
to
$('<input />').attr({'type':'hidden'})
and it solved my problem.
Thanks everyone.
jQuery.error() (which throws the message passed as an argument), is totally different to the error handler specified in an AJAX call.
jQuery.error() is used internally by jQuery (search for "error("). You should debug your code and follow the stack trace to find which of your methods is calling the jQuery method which is erroring.
Just a guess, but do you somewhere use $.error() inside your code? If yes: don't use it.
<edit>
However, this error comes from jQuery.error().
The original error-function looks like this:
error: function( msg ) {
throw msg;
}
You may test it without jquery:
(function( msg ) {
throw msg;
})('errormessage');
You'll get the same error.
If you don't use jQuery.error() maybe you use some plugin that uses it.
You may override this (buggy?) function by executing the following right after the embedded jquery.js:
jQuery.error=function(){}
</edit>
Related
I have a JQuery ajax request that can return error status and messages.
To handle them I use this code :
$.ajax("url", {
options: options
}).done(function(text, statusText, data) {
//Manage data
}).fail(function(data) {
//Manage fail
});
In the fail handle I want, in case of 500: internal server error, to open a new tab with the response text (for debug purposes)
I do it this way :
if (data.status === 500) {
var w = window.open("App error", "blank");
w.document.write(data.responseText);
}
And it works !
Except one point : my browser loads the page, the content is displayed (and as it's static content all of this is not a real problem), but the tab is marked as loading... Loading... Loading...
I'm using Firefox 63.0(64bits).
Does anyone know where this comes from ? It's not really annoying, it's just a (fun ?) behavior I don't understand.
Here is a fiddle on which I get the exact same behavior.
It has to do with the w.document.write line. If you close the document, the loader will finish. Change the code to:
if (data.status === 500) {
var w = window.open("App error", "blank");
w.document.write(data.responseText);
w.document.close();
}
Source: Open about:blank window in firefox
The problem is that you are opening a tab without an url, and most browsers expect an url, that's what I do in order to get rid of it:
const newWindow = window.open('#');
if (newWindow) {
newWindow.addEventListener('load', () => {
newWindow.document.open();
newWindow.document.write(request.responseText);
newWindow.document.close();
newWindow.stop();
}, true);
You can replace # with any url path that doesn't exist, the important thing is that once it's loaded, you'll be able to override the content.
It's not the best solution but at least it makes the trick
This particular chunk of code is receiving an error of a missing semi-colon. What is odd is that the code itself is a direct duplicate of code that is saving without the error in another file.
This is the only message I am receiving from the compiler (Hubspot). The error is supposedly happening on the first line. I am limited in my Javascript knowledge and thus am unable to verify with certainty that the error message I am receiving is correct. Could it be an incorrect error? If it is not, could someone help me with correcting what is causing the error?
Thanks in advance.
var isIE = /*#cc_on!#*/false || !!document.documentMode; // At least IE6
if (isIE) {
$("#svg >g, #logos, #logos > g, g.text, .services-svg, .services-svg > g, #a-experience-svg-figure,#experience-a-svg-group a.paragraph.link")
.each(function() {
$(this).attr('transform', $(this).css('transform'));
});
}
In your code fragment are not problem with semicolon.
Does anyone have any idea how to resolve this error?
The google devt tools does not pinpoint the location of the erroneous code which makes it hard to troubleshoot.
Im currently on Meteor and MongoDB.
Ive searched for Unexpected tokens, theres A, N, C but M is not common.
What Ive read is it might be a server commenting problem as it adds random letters and non-recognizable scripts.
Any suggestions?
ng-inspector maintainer here (I don't have enough rep to add a comment)
I'm sorry that the extension caused issues for you. For what it's worth, we've since updated it (v0.5.8) to handle exceptions from the postMessage data.
I've got the exact same problem, and it's happening at line 1472 in ng-inspector.js at JSON.parse(eventData);
The reason is presumably that event.data is holding some kind of setImmediate string (which begins with the letter 'M') - "Meteor._setImmediate.0.5014774943701923.5"
Here are the five lines in ng-inspector.js leading up to the JSON.parse():
window.addEventListener('message', function (event) {
// Ensure the message was sent by this origin
if (event.origin !== window.location.origin) return;
var eventData = event.data;
if (!eventData || typeof eventData !== 'string') return;
eventData = JSON.parse(eventData);
the debugger shows this stuff in the event object:
event = MessageEvent {data: "Meteor._setImmediate.0.5014774943701923.5", origin: "http://localhost:3000", lastEventId: "", source: Window, ports:
ng-inspector.js is an angular extension for Chrome so I guess all we have to do is uninstall it now that we are using Meteor!
Yes, I can confirm that I have uninstalled the Angular inspector from the Chrome extensions and that the problem is solved.
I have been writing an ASP.NET MVC 4 project in VS. I had it working perfectly in an older version of Firefox and in IE 11. It still works great in IE 11, but after I updated FF to 35.0.1, My script is not working. How do I get my script to work in the newest version of Firefox?
My _Layout view contians the following script:
......
#Scripts.Render("~bundles/jquery")
<script>
$.ajax({
url: '#Url.Action("Action", "Controller")',
type: 'post',
cache: 'false,
async: 'true',
data: '{}',
success: function(result){
$('#progress').html(result);
}
});
$(document).ready(function(){
function RefreshPartial(){
setTimeout(function(){
loadPartialView();
RefreshPartial();
}, 3000);
}
RefreshPartial();
});
</script>
#RenderSection("scripts", required: false)
</body>
......
In Firefox/Fox It hits the
"$(document).ready(function () {"
line then jumps to the bottom of the script
});
before going to the Jquery. It never comes back to my inline JS. It throws the following exception: "SyntaxError: An Invalid or illegal string was specified" at the "if" statment below:
3093 for ( ; list && firingIndex < firingLength; firingIndex++ ) {
3094 if ( list[ firingIndex ].apply{ data[ ], data[ 1 ] ) == false && options.stopOnFalse ) {
memory = false;
break;
}
}
It loops through the for statment several times and then throws an error at the same if statement: "TypeError: Constructor Document requires 'new'".
It never runs my inline script so my partial view is never loaded. Again, this only happens in the newest version of FF.
Firefox 35.0.1 does not like th e long version of:
$(document).ready(function(){
My code works using the shorthand version:
$(function() {
I don't know why, but it worked right away.
I see not reason why it should not work... Have you try doing a simple jquery alert? does it work? remove the ajax call and do the alert if you get the alert to work, then your jquery is working. otherwise you might not been linking jquery properly. if the alert works try a simple hit or miss ajax call.
$.ajax( "example.php" )
.done(function() {
alert( "success" );
})
.fail(function() {
alert( "error" );
})
.always(function() {
alert( "complete" );
});
Edit: there is not reason why FF would not work with $(document).ready(function(){});
I am currently using it for a web service and it works just fine with: safari, chrome, FF and IE plus four or five more mobile browsers.
The code works fine in Firefox but not in IE. I have done a lots of research, but still couldn't find solution.
This function is called from a button on coldfusion cfc file to allow users manually update a report status. I can exactly get what I want in FF, but it doesn't work in IE. I added the alert message to debug the problems. I could get 'Review Status 1', but not 'Review Status 2'. The error form IE is "The object doesn't support this property or method.".
function updateReviewStatus(rowNum) {
alert ("Review Status 1");
var strlen= $("locFund_"+rowNum).innerHTML.split("-")[0].trim().length;
alert("Review status 2");
$("cerStatus_"+rowNum).update("Review Recommended");
$("cerStatus_"+rowNum).style.color="green";
$("cerStatus_Bn_"+rowNum).hide();
new Ajax.Request("?method=updateUIReviewDB",
{
parameters: {
FiscalYear: $("fyfp_"+rowNum).innerHTML.substr(0,4),
FiscalPeriod : $("fyfp_"+rowNum).innerHTML.substr(4,2),
PIUniversalID : "#JSStringFormat(Arguments.PIUniversalID)#",
OPLocCode : $("locFund_"+rowNum).innerHTML.split("-")[0].trim().substr(strlen-1,1),
OPFund : $("locFund_"+rowNum).innerHTML.split("-")[1].trim()
},
method: "post"
});
}
var strlen= $("locFund_"+rowNum).innerHTML.split("-")[0].trim().length;
IE actually has trim() for strings? try
var strlen= $("locFund_"+rowNum).innerHTML.split("-")[0].strip().length;