0

I have following code:

<body onload="LoadData()">
    <table id="myTable">
    </table>
</body>

And I have Javascript function like :

<script type="text/javascript">
    function LoadData()
    {
        var sTempTableRow='<tr><td>cell-1 </td><td>cell-2 </td><td>cell-3 </td><td>cell-4 </td></tr>'
        $('#myTable').append(sTempTableRow);
    }
</script>

I have tried numerous times and at all the times face an exception like Microsoft JScript runtime error: Object expected.

Please tell me what is the problem here.

1
  • check your jquery js file is place in correct path Commented Nov 10, 2012 at 12:29

2 Answers 2

1

Instead if the onload event use jquery's ready:

<script type="text/javascript">
    $(document).ready(function()
    {
      var sTempTableRow='<tr><td>cell-1 </td><td>cell-2 </td><td>cell-3 </td><td>cell-4 </td></tr>';
      $('#myTable').append(sTempTableRow);
    });
</script>
<body>
    <table id="myTable">
    </table>
</body>
Sign up to request clarification or add additional context in comments.

1 Comment

Mr. Kirill Ivlev .i can't user $(document).ready(function(){} because of i use it in a showmodaldialog window where i pass parameter when i user $(document).ready(function(){} function i face an exception like : $(document).ready(function () { var _oPerameter = window.dialogArguments; _oPI = _oPerameter.PI; debugger; RefreshPIProducts(_oPI.web_PIProducts); }); As a result i use onLoad function
0

you can find the solution :

$(document).ready(function(){
     var sTempTableRow='<tr><td>cell-1 </td><td>cell-2 </td><td>cell-3 </td><td>cell-4 </td></tr>'
     $('#myTable').append(sTempTableRow);
    });

​and remove the onload statement.

You can find the solution here.

1 Comment

Mr. Zakaria i can't user $(document).ready(function(){} because of i use it in a showmodaldialog window where i pass parameter when i user $(document).ready(function(){} function i face an exception like : $(document).ready(function () { var _oPerameter = window.dialogArguments; _oPI = _oPerameter.PI; debugger; RefreshPIProducts(_oPI.web_PIProducts); }); As a result i use onLoad function

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.