Wednesday, 2 October 2013

uncaught TypeError on savebutton

uncaught TypeError on savebutton

I was haveing problems with a save button on a website i am working on. i
get this error in chrome: Uncaught TypeError: Cannot read property
'contentWindow' of undefined
and this error in firefox: TypeError:
$(...).children(...).children(...).children(...)[3] is undefined
here is the pice of code where the error is located:
$('.btnAddProduct').click(function(){
if(busy != 1){
busy = 1;
var error = 0;
if($('input[name="txtTitle"]').val() == ''){
error = 1;
alert('Het titel veld is nog leeg');
$('input[name="txtTitle"]').focus();
}
if(error != 1){
$('.content_load_icon').html('<img
src="../../includes/images/layout/load_small.gif" />');
var content =
$('#cke_ckeditor').children().children().children()[3].contentWindow.document.childNodes[1].childNodes[1].innerHTML;
$.ajax({
url: '../../action/ac_productbeheer.php?a=add',
type: 'POST',
data: {txtTitle: $('input[name="txtTitle"]').val(),
txtParentPage: $('select[name="txtParentProduct"]').val(),
txtContent: content, create: true},
success: function(data, textStatus, xhr) {
$('.content_load_icon').html('');
$('.txtContentConsole').html('Product succesvol
opgeslagen!').show().delay(2000).fadeOut(200);
busy = 0;
saved = 1;
window.location =
'../../modules/productbeheer/index.php';
},
error: function(xhr, textStatus, errorThrown) {
$('.content_load_icon').html('');
$('.txtContentConsole').html('Fout bij opslaan!
Probeer het later nog een
keer.').show().delay(2000).fadeOut(200);
busy = 0;
}
});
} else {
error = 0;
busy = 0;
}
}
});
I hope one of you guys/girls can help me with this problem.

No comments:

Post a Comment