jquery-1.10.2.min.js version will trigger 404 on chrome only (minipad supposed issue)

Hi. I get a 404 not found in the chrome console and my javascript does not run.

I read that it is the minipad known issues, so i

1)Included the minimap file

2)Removed the minipad call from inside the js file.

Finally what i found out is that if i do this :
www.mysite.com
, it will work fine but if i do this mysite.com , will trigger 404.

So what can i do to make chrome see the www ?  Inside IIS maybe? So should i post in a different forum?

Thanks.

Could you post what your existing jQuery code or markup currently looks like? 

It’s also important to ensure that all of your code that references jQuery is placed within a "document" ready block that generally looks like this :

<!-- jQuery Reference here -->
<script type='text/javascript'>
   $(document).ready(function(){
          // jQuery code here
   });
</script>

or this :

<!-- jQuery Reference here -->
<script type='text/javascript'>
   $(function(){
          // jQuery code here
   });
</script>

Hi. Only thing i can think of is maybe doing something wrong with the location.href (?)

I call homeld function right after the document ready function that is in the markup:

//markup loads
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    
<script src="js/jquery-1.10.2.min.js" type="text/javascript"></script>
<script src="js/bootstrap-transition.js" type="text/javascript"></script>
<script src="js/bootstrap-carousel.js" type="text/javascript"></script>
<script src="js/bootstrap-alert.js" type="text/javascript"></script>
<script src="js/bootstrap-modal.js" type="text/javascript"></script>
<script src="js/bootstrap-dropdown.js" type="text/javascript"></script>
<script src="js/bootstrap-scrollspy.js" type="text/javascript"></script>
<script src="js/bootstrap-tab.js" type="text/javascript"></script>
<script src="js/bootstrap-tooltip.js" type="text/javascript"></script>
<script src="js/bootstrap-popover.js" type="text/javascript"></script>
<script src="js/bootstrap-button.js" type="text/javascript"></script>
<script src="js/bootstrap-collapse.js" type="text/javascript"></script>
<script src="js/bootstrap-typeahead.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.18.custom.min.js" type="text/javascript"></script>
<script src="js/jquery.smooth-scroll.min.js" type="text/javascript"></script>
<script src="js/lightbox.js" type="text/javascript"></script>
 <script src="js/lightbox.js" type="text/javascript"></script>

    <script src="js/modernizr.custom.js" type="text/javascript"></script>
    <script src="js/lightbox-2.6.min.js" type="text/javascript"></script>
    <script src="javascript/homejs.js" type="text/javascript"></script>
  <meta charset="utf-8" content="text/html;" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="css/bootstrap-responsive.css" rel="stylesheet" type="text/css" />   
<!--[if lt IE 9]><script src="js/html5.js"></script><![endif]-->
<link href='http://fonts.googleapis.com/css?family=Lato:300' rel='stylesheet' type='text/css' />
    <link href="css/lightbox.css" rel="stylesheet" type="text/css" />
    <link href="css/screen.css" rel="stylesheet" type="text/css" />
    <link rel="stylesheet" href="css/reset.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/layout.css" type="text/css" media="all" />
<link rel="stylesheet" href="css/style.css" type="text/css" media="all" />
 <script type="text/javascript">
     $(document).ready(function() {        

         var menu = document.getElementById("menu1");
         $(menu).each(function(index) {
             $('a').each(function(index) {
                 if ($(this).parent().hasClass("hom"))
                     $(this).parent().addClass("active");
             });
         });
                 
         homeld();

     });           
 </script>




// javascript file: homejs.js
function homeld() {
    var str = window.location.href;
    str = str.substring(0, str.length - (str.length - str.lastIndexOf("/") - 1));
    //loading...
    $("#img1").show();
    $("#ph1").show();
    $("#phnewslab").hide();
    $("#br1").hide();
    $.ajax({
        type: "POST",
        url: "Servicetopnews.svc/returntopnews",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            $("#img1").hide();           
            $("#ph1").hide();
            $("#phnewslab").show();
            $("#br1").show();
            try {
                var oRetVal = response.d;
                $.each(oRetVal, function (index, topnews) {


                    var day = new Date().getDay();
                    switch (index) {
                        case 0:
                            $("#news1date").text(topnews.mydate);
                            $("#news1text").text(topnews.header);
                            $("#news1text").attr('href', str + 'news.aspx?article=' + topnews.url);                          
                            break;
                        case 1:
                            $("#news2date").text(topnews.mydate);
                            $("#news2text").text(topnews.header);
                            $("#news2text").attr('href', str + 'news.aspx?article=' + topnews.url);
                            break;
                        case 2:
                            $("#news3date").text(topnews.mydate);
                            $("#news3text").text(topnews.header);
                            $("#news3text").attr('href', str + 'news.aspx?article=' + topnews.url);
                            break;

                    }

                    //    alert(topnews.mypic);                      

                }
            )
            }
            catch (ex) { alert(ex) }
        },
        failure: function (msg) {
            alert(msg);
        }
    });
};

Are you receiving any additional errors within your Console within your browser (you can check this using the Developer Tools (F12))? If not, there are a few things that you can try to do to help troubleshoot this issue.

Is there any reason that you are using the getElementById function since you are already using jQuery? You could simplify the code within your document-ready block to the following (assuming you want to grab all <a> elements within your menu :

$(document).ready(function() {        
         // Set up your menu
         $("#menu a").each(function(index) {
             if ($(this).parent().hasClass("hom")){ $(this).parent().addClass("active"); }
         });
         // Wire up a few things
         homeld();
});   

As you mentioned, you were concerned if your actual URL was correct. The easiest way to check this would be to place a few Javascript alert calls into your code so that it would notify you of your values :

var str = window.location.href;
str = str.substring(0, str.length - (str.length - str.lastIndexOf("/") - 1));
alert(str);

An easier approach still would be to use the
debugger; keyword
. Basically, you would just need to add the debugger keyword within your function call and open up the Developer Tools (F12) within your browser and then refresh your page. You’ll see that you will hit a breakpoint and will be able to step
through your Javascript code just as you would within Visual Studio :

function homeld() {
    // Begin debugging
    debugger;
    var str = window.location.href;
    str = str.substring(0, str.length - (str.length - str.lastIndexOf("/") - 1));
    //loading...
    $("#img1").show();
    $("#ph1").show();
    $("#phnewslab").hide();
    $("#br1").hide();
    $.ajax({
        type: "POST",
        url: "Servicetopnews.svc/returntopnews",
        data: "{}",
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (response) {
            // Debug your POST request
            debugger;

            $("#img1").hide();           
            $("#ph1").hide();
            $("#phnewslab").show();
            $("#br1").show();
            try {
                var oRetVal = response.d;
                $.each(oRetVal, function (index, topnews) {
                    var day = new Date().getDay();
                    switch (index) {
                        case 0:
                            $("#news1date").text(topnews.mydate);
                            $("#news1text").text(topnews.header);
                            $("#news1text").attr('href', str + 'news.aspx?article=' + topnews.url);                          
                            break;
                        case 1:
                            $("#news2date").text(topnews.mydate);
                            $("#news2text").text(topnews.header);
                            $("#news2text").attr('href', str + 'news.aspx?article=' + topnews.url);
                            break;
                        case 2:
                            $("#news3date").text(topnews.mydate);
                            $("#news3text").text(topnews.header);
                            $("#news3text").attr('href', str + 'news.aspx?article=' + topnews.url);
                            break;

                    }
                }
            )
            }
            catch (ex) { alert(ex) }
        },
        failure: function (msg) {
            alert(msg);
        }
    });
};

Hi. I get no additional errors. I may have used some JS instead of Jquery but i don’t think that will give me a 404 not found.

Also if i recall, debugger only works with Iexplorer, i really detest Iexplorer like most web developers. I use firebug a lot, and i don’t see any additional errors.

I am starting to think that the only solution would be to get rid of the Jquery version for a new one. Also, if you look at the code you will notice that i also use an older Jquery version. Would there be a problem there?

Thanks.

 

sapator

Also if i recall, debugger only works with Iexplorer, i really detest Iexplorer like most web developers. I use firebug a lot, and i don’t see any additional errors.

As long as you have the debugger; keyword present within your Javascript code and you have the Developer Tools (F12) open when your code is executing, it should work just fine in any browser. Basically, just hit F12 and refresh your page and you should hit
it.

sapator

I am starting to think that the only solution would be to get rid of the Jquery version for a new one. Also, if you look at the code you will notice that i also use an older Jquery version. Would there be a problem there?

Unless something is just explicitly wrong with the jQuery file that you are presently using, it should be working. Could you post a screen-shot of exactly what your 404 error looks like and the exact URL  that it is trying to target?

Hey, as i see it tries to call the relative web service and fails with a 404 not found.

returntopnews <div class="network-cell-subtitle" style="box-sizing: border-box; font-weight: normal; color: #e60000; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">/Servicetopnews.svc</div> POST 404 <div class="network-cell-subtitle" style="box-sizing: border-box; font-weight: normal; color: #e60000; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">Not Found</div> text/plain jquery-1.10.2.min.js:6 <div class="network-cell-subtitle" style="box-sizing: border-box; font-weight:
normal; color: #e60000; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">Script</div>
185 B <div class="network-cell-subtitle" style="box-sizing: border-box; font-weight: normal; color: #e60000; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">0 B</div> 173 ms <div class="network-cell-subtitle" style="box-sizing: border-box; font-weight: normal; color: #e60000; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;">173 ms</div>

Hi sapator,

404 not found error means that your ajax  may fire a request with wrong Url.

Please check the right url for ajax,then suggest that you can press F12 ,click "NetWork" tab to capture the respond /request information.

Best Regards,

Kevin Shen.

Hi. But would be also wrong either doing http://mysite or
http://ww.mysite?

It works fine in www.mysite

You might try using something like the ResolveUrl() method to reference your jQuery library to ensure that it is targeting the proper location :

<script src="<%= ResolveUrl("~/js/jquery-1.10.2.min.js") %>" type="text/javascript"></script>

Hi sapator,

If your issue just happen in chorme which is not supported here ,I suggest that you can post your issue to their forum for a professional solution.

Best Regards,

Kevin Shen.

Hi. No no just in chrome.

Rion i will try that tomorrow.

thanks.

Doesn’t work.

Maybe it’s an wcf web.config issues?

I have this one:

<identity>
          <dns value="localhost" />
        </identity>

Is that ok?

Leave a Reply