-1

i am getting script error in Jquery. please suggest how to resolve this. Script error message displayed is "HTML parsing error: unable to modify the parent container element before the child element closed". code:0 line:0 char:0. My Jquery code is:

      <script type="text/javascript">

     (function($) {
     var search=window.location.search.substring(1);
     var page=search.split("=");
     var location=window.location.toString();
     var url=location.split('?')[0];         

     if(page[1]=='custDetails'){

       $(document).ready(function(){
       $('#message').dialog('open');
       $(document).ready(function(){
       $('#pop').click(function(){
      $('#message').dialog('open');
       return false;
         });
       });
      });
     }   // end of if      
        else {
        $(document).ready(function(){
        $('#pop').click(function(){
        $('#message').dialog('open');
        return false;
          });
        });

        }  // end of else

        $('#message').dialog({
        width:200,
        autoOpen:false,
        buttons:{ 
           Close:function() {
       $ (this.dialog('close');
       $ ('#message').replaceWith('url');
                 }
              } 
          });

       $('#page').click((function(event){            
         window.print();
          });

        })  ($);
      </script>

when i remove $('#message').dialog({}); component it doesn't throw script error. please suggest me the cause.

6
  • 1
    ...and include the error message. Commented Dec 16, 2011 at 12:53
  • 2
    Why do you have so many $(document).ready event handlers? One would suffice. Commented Dec 16, 2011 at 12:55
  • If you formatted your code, errors would be easier to spot. Commented Dec 16, 2011 at 13:16
  • I am downvoting simply because this is just so badly done from such a basic stand point - I know that is not totally in the spirit of this site and I never do this but gee... Commented Dec 16, 2011 at 13:28
  • @Jørgen , i got this error message. "HTML parsing error: unable to modify the parent container element before the child element closed". code:0 line:0 char:0 Commented Dec 16, 2011 at 18:58

3 Answers 3

1

Full of syntax errors ...

$('#message').dialog($  // << ERROR 1 should be {
        width:200; // << ERROR 2 the ; should be ,
        autoOpen:false; // << ERROR 3 the ; should be ,
        buttons.{close:function() { // << ERROR 4 the . should be :
       $ (this.dialog('close'); // << ERROR 5 the $(this should be $(this).
          }}
         });

all together it should be

    $('#message').dialog({
        width:200,
        autoOpen:false,
        buttons: { close:function() {
                          $(this).dialog('close');
                         }
                 }
        });
Sign up to request clarification or add additional context in comments.

Comments

0

There are several syntax errors here:

$('#message').dialog($
    width: 200;
    autoOpen: false;
    buttons. {
    close: function() {
        $(this.dialog('close');
        }
    }
});
$('#page').click((function(event) {
    window.print();
});

Try this:

$('#message').dialog({
    width: 200,
    autoOpen: false,
    buttons: {
        close: function() {
            $(this.dialog('close');
            }
        }
    });
});

$('#page').click(function(event) {
    window.print();
});

2 Comments

thanks epignosisx, still it is showing script error until i don't remove
@user1057697 you have one more syntax error. Look for the line $ (this.dialog('close'); It should be $(this).dialog('close'); You should try jslint.com. It will identify this sort of errors.
0

If the error is there, are you sure you included jQueryui js file?

Something like:

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

after you included your jQuery js file?

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.