Reputation: 51
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.
Upvotes: -1
Views: 1628
Reputation: 76910
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?
Upvotes: 0
Reputation: 196236
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');
}
}
});
Upvotes: 1
Reputation: 6192
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();
});
Upvotes: 0