开发者

I cannot use JQuery in login page?

I'm with a problem than right now i'm not understanding..

I'm using JQuery to render a icon "loading ajax" always than a request page is done.

All my pages derives from master page, but login page doens't.

What happens is that page (login) i cannot use jquery

In login page im including to jquery library 开发者_JS百科and using the following code to test

<script type="text/javascript">
            $(function(){
                console.log('blbalbl');
               });   
        </script>

but $ is not recognized..

If i remove

$(function(){ 

and leave

console.log('blabla');

blablbal will appear in console..

Anybody knows what is happening?

regards


Guys i already included the library jQuery but still not work

<script language="javascript" type="text/javascript" src='<%=ResolveUrl("~/js/jquery-1.4.1.min.js") %>'></script> 
<script type="text/javascript">
  $(function() { 
    console.log('blbalbl'); 
  }); 
</script>

In my master page the script works, but in the login doesn't

I already try no conflict with .$noConflict but the problem is than $ is unrecognized.


You are not loading the jQuery library.

http://docs.jquery.com/Tutorials:How_jQuery_Works

Look for a line like this in your master page

<script type="text/javascript" src="jquery.js"></script>

or

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>

so just add one of these to your page with the problem and then it will work.


A wild guess. If you are using any other library then you have to use jQuery.noConflict()

$.noConflict();
  jQuery(function() {
      console.log('blbalbl');
  });

Also check that your reference for the jQuery file is the right one. You can use firebug to find out that.

<script src="jQuery.js" type="text/javascript></script>


Try

jQuery(document).ready(function {
    //do your thang
});

If that works, you must have some kind of conflict. If not, you need to make sure you are loading jQuery correctly.


You mention a Master page, is this an Asp.net site? Are you using Forms Authentication? If so you will need to add a section to your web.config to give all users access to your javascript files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜