开发者

JQuery onBlur script not working

I got this script

   $("#person").blur()(function() {
      $.ajax({
      type: 'GET',
      url: 'vsfill.html',
      dataType: 'json',
      data: ({accountId:accountid}),
      success: function(data) {
        if (data!=null&&data!='') {
            $('#person').val(data.accountId);
            $('#responsableName').val(data.givenName);
            $('#resposableMail').val(data.Mail);
        }
      }

});



      });

Error console gives me that .blur is not a function.

My libra开发者_StackOverflow社区ries:

    <script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
    <script type="text/javascript" src="js/jquery.bubblepopup.v2.3.1.min.js"></script>
<script src="js/modernizr-1.6.min.js"></script>
    <link rel="stylesheet" href="js/jquery-autocomplete/jquery.autocomplete.css" type="text/css" />
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.autocomplete.js"></script>
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.combobox-1.0.3.js"></script>
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.ui.autocomplete.js"></script>
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.ui.core.js"></script>
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.ui.position.js"></script>
    <script type="text/javascript" src="js/jquery-autocomplete/jquery.ui.widget.js"></script>

What's wrong?


Try this (no open-close parenthesis after blur):

   $("#person").blur(function() {
      $.ajax({
      type: 'GET',
      url: 'vsfill.html',
      dataType: 'json',
      data: ({accountId:accountid}),
      success: function(data) {
        if (data!=null&&data!='') {
            $('#person').val(data.accountId);
            $('#responsableName').val(data.givenName);
            $('#resposableMail').val(data.Mail);
        }
      }});
   });

See the jQuery documentation for more info.


Try changing

$("#person").blur()(function() {

To:

    $("#person").blur(function() { 
   //code here
});


Your function should be passed as a parameter to the blur() function itself. Also I can't see the jQuery JS file in your libraries: only plugins.

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

Should be enough.


Instead of

$("#person").blur()(function() {
   ...
});

Try:

$("#person").blur((function() {
   ...
});

See the ")" after blur?

Also, I don't see a jquery itself among your libraries. You will need it to use jquery-ui and all the rest.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜