Click here to Skip to main content
15,888,009 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
HTML
<script type="application/javascript">
     $(function () {
         $('#btnUsingjQuery').click(function () {
             $.ajax({
                 url: "https://maps.googleapis.com/maps/api/js?key=12345",
                 dataType: 'jsonp',
                 success: function (results) {
                     window.location.href = "www.google.com";
                 }
             });
         });
     });
     </script>

this is my jquery code will trigger an API,matter fail or success it will redirect to google.com.
i faced error after click the button : Refused to execute script from API because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

What I have tried:

any idea why???thanks for help.
Posted
Updated 1-Dec-16 19:34pm
Comments

1 solution

i hope script type should be
text/javascript


try this:

HTML
<script type="text/javascript" >
 
    $(function () {
        $('#btnUsingjQuery').click(function () {
            $.ajax({
                url: "https://maps.googleapis.com/maps/api/js?key=12345",
                dataType: 'jsonp',
                success: function (results) {
                    window.location.href = "http://www.google.com";
                }
            });
        });
    });
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900