jQuery is not functional on Mozilla Firefox
I have problem with my ASP.NET MVC app when use Mozilla Firefox. I'm use JQuery and this code is not functional. In Google Chrome and IE 8 everything is fine. How solve this. If necessary I will post parts of my JQuerycode
In Site master page I include scripts, something like this:
<script type="text/javascript" src="../../Scripts/jquery-1.3.2.js"></script>
<script src="../../Scripts/jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript" src="../../Scripts/ui.core.js"></script>
<script type="text/javascript" src="../../Scripts/ui.selectable.js"></script>
<script type="text/javascript" src="../../Scripts/ui/ui.accordion.js"></script>
<script type="text/javascript" src="../../Scripts/MicrosoftAjax.debug.js"></script>
<script type="text/javascript" src="../../Scripts/MicrosoftMvcAjax.debug.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.dataTables.js"></script>
<script type="text/javascript" src="../../Scripts/ui/ui.datepicker.js"></script>
<script type="text/javascript" src="../../Scripts/jquery.bstablecrosshair.js"></script>
<script src="../../Scripts/jquery.jqGrid.min.js" type="text/javascript"></script>
<script src="../../Scripts/jqModal.js" type="text/javascript"></script>
<script src="../../Scripts/jqDnR.js" type="text/javascript"></script>
Most important part of code who is not work on Firefox:
<script type="text/javascript">
$(document).ready(function() {
$('input:radio').click(function() {
var num = "";
var location = "";
var loc = $("input:checked").val();
var lenght = loc.lenght;
var tmp = loc.substring(0, 2);
if (tmp == "SA") {
num = loc.substring(2, lenght);
location = "SA";
}
if (tmp == "ST") {
num = loc.substring(2, lenght);
location = "STH";
开发者_如何转开发 }
if (tmp == "SH") {
num = loc.substring(2, lenght);
location = "SASTH";
}
if (tmp == "NE") {
num = loc.substring(2, lenght);
location = "NEW";
}
var article_number = $("input[id=" + num + "]").val();
//alert(article_number +" "+ num);
$.post("/ImportXML/DevAccEditTempTable", { location: location, article_number: article_number, loc: num }, function(data) {
if (data.error == "Error") {
alert("Error: quantity is too large! ");
window.location.href = "/" + data.redirect;
}
else {
window.location.href = "/" + data.redirect;
}
}, "json");
});
});
</script>
For basic Javascript/jQuery debugging, try this:
<script type="text/javascript">
alert("Javascript works!");
$(document).ready(function(){
alert("jQuery works!");
});
</script>
If you only get the first alert window, it means that something is wrong with the way that jQuery is referenced. If you don't get either window in Firefox (but you do in other browsers), you'll want to make sure that Javascript is turned on in Options > Content, and you'll want to make sure that no plugins would be blocking Javascript.
(Edited, because more code snippets have been added to the original post:)
In the second code snippet that you posted, "loc.lenght" should be "loc.length".
$('input:radio').click(function() {
var num = "";
var location = "";
var loc = $("input:checked").val();
var lenght = loc.lenght;
var tmp = loc.substring(0, 2);
alert(loc.substring(2, lenght));
It seems like the line var lenght = loc.lenght;
is causing problems because loc.lenght
probably isn't returning the value that you want (because lenght
isn't a property). I've added an alert
to your code, which should pop up the string that you calculate in the if
statements following this section. You should run this code, with the alert
in all three browsers to see what the difference is.
I'm not sure why this would be working in some browsers but not Firefox. Maybe loc.lenght
is returning 0 in IE 8 and Chrome, but null
in Firefox, which would break the whole calculation.
Check whether Javascript is disabled in Firefox. Also, check for FF plugins such as adblockers that may be blocking some Google URLs, which could be a problem if you are letting Google host the JQuery library.
Chances are your problem is that you mispelled the word Lenght
.
var lenght = loc.lenght;
<-- Should be loc.length
Jquery has worked just fine for me on firefox, perhaps if you post the bit that is giving you a hard time the community here can point you in the right direction.
Install fiddler, browser act differently, some a strict and some are loose, you should understand that Chrome fixes problems in your code without you knowing, and firfox might not.
check Chrome Debugger Ctrl-Shift-J
and install fiddler.
If the posted scripts are the ones you're working with, it looks like you haven't actually included jQuery.
精彩评论