0

I am trying to using a tree structure on my JSP Page along with Jquery. Tree Structure requires to import few Jquery files. When I run the JSP page, I get the error code "Object doesn't support this property or method".

I tested the code by running the Tree Structure (Dyna Tree) code seperately and it works fine. Then I tried running the Jquery that I have written and it also works fine. The above mentioned error only appears if I integrate both the code. I have writted my custom code and error where exactly it appears. NOTE : fm is name of the form on my JSP Page.

  <script type="text/javascript">
        var url;
    function newUser(){
        $('#dlg').dialog('open').dialog('setTitle','Create New Access');
        $('#fm').form('clear');   // ERROR AT THIS LINE
        url = 'saveaccess.jsp'; 
    }
    function editUser(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            $('#dlg').dialog('open').dialog('setTitle','Edit Access');
            $('#fm').form('load',row);
            alert("test"+row);
            //url = 'AddNeditApplication.jsp';
        }
    }
    function saveUser(){
        $('#fm').form('submit',{
            url: url,
            onSubmit: function(){
                return $(this).form('validate');
            },
            success: function(result){
                //var result =new Object();
                alert(result);

                if (result){
                    $('#dlg').dialog('close');      // close the dialog
                    $('#dg').datagrid('reload');    // reload the user data
                } else {
                    $.messager.show({
                        title: 'Error',
                        msg: result.msg
                    });
                }
            }
        });
    }
    function removeUser(){
        var row = $('#dg').datagrid('getSelected');
        if (row){
            $.messager.confirm('Confirm','Are you sure you want to remove this Access?',function(r){
                if (r){
                    $.post('AddNeditApplication.jsp',{id:row.id},function(result){
                        if (result.success){
                            $('#dg').datagrid('reload');    // reload the user data
                        } else {
                            $.messager.show({   // show error message
                                title: 'Error',
                                msg: result.msg
                            });
                        }
                    },'json');
                }
            });
        }
    }

</script>
4
  • 2
    Which line does this error refers to? Commented Oct 8, 2012 at 8:40
  • $('#fm').form('clear'); // ERROR AT THIS LINE Commented Oct 8, 2012 at 8:49
  • Can you post the segment of your relevant markup (HTML)? Commented Oct 8, 2012 at 9:44
  • Also if you're using firefox and firebug on the console after the page has loaded type: $('#fm') and see if what is returned is actually an object. If not then your form fm hasn't been rendered correctly Commented Oct 8, 2012 at 10:00

2 Answers 2

1

$('#fm').form('clear'); - Whenever JavaScript says "Object doesn't support this property or method", it's talking about the . operator. Which means the object returned by calling $('#fm') doesn't support the method form.

I can't find any documentation in the jQuery API for a form method. Perhaps you're trying to use EasyUI? Are you including the EasyUI scripts in your HTML in addition to jQuery (After jQuery, and before your code)?

Something like this:

<script src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>

...?

Sign up to request clarification or add additional context in comments.

6 Comments

Yes, I am including JEASYUI addition to Jquery <link rel="stylesheet" type="text/css" href="jeasyui.com/easyui/themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="jeasyui.com/easyui/themes/icon.css"> <link rel="stylesheet" type="text/css" href="jeasyui.com/easyui/demo/demo.css"> <script type="text/javascript" src="jeasyui.com/easyui/jquery.easyui.min.js"></script>
Are you loading EasyUI after jQuery?
Yes, first I am loading Jquery and followed by EasyUI.
That means $('#fm') isn't returning anything then doesn't it?
Lee, fm is returning value while I running the code without the tree structure code.
|
0

Reasons for Object doesn't support this property or method' exception:

  1. Check and compare the browser version compatibility/support of the Jquery version. i.e. IE8 does not support Jquery2x versions. In this scenario, use versions accordingly
  2. The order of the files are wrong in your html/aspx file. Change order.. for example..

From...

 <script src="js/jquery.easing.js"></script>      
    <script src="js/jquery.js"></script>
    <script src="js/jqueryFileTree.js"></script>
    <script src="js/default.js"></script>
 <script src="js/jquery-1.4.1-vsdoc.js"></script>
    <script src="js/jquery-1.4.1.js"></script>
    <script src="js/jquery-1.4.1.min.js"></script>

To:

 <script src="js/jquery-1.4.1-vsdoc.js"></script>
<script src="js/jquery-1.4.1.js"></script>
<script src="js/jquery-1.4.1.min.js"></script>
<script src="js/jquery.js"></script>
<script src="js/jqueryFileTree.js"></script>
<script src="js/default.js"></script> 
  <script src="js/jquery.easing.js"></script>

I was getting similar exception and now got resolved.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.