PDA

View Full Version : Problem with MsgBox never appears.



marxan
23 Nov 2010, 1:29 AM
Hi,

I have a formpanel with a textarea field and a save button. When I click on save. It call a page that insert a record in the DB and then should display a message box "Record saved".

My code works fine with FireFox. In IE, the record is saved but the screen is stuck in the waiting Msg.

Error Message: Syntax error...

I have read and reread my code, I could not find any error of syntax. If someone could have a look on this code and maybe find what my blinded eyes coder could not see.

Thanks in advance.


function changeUrl(url) {
location.href = url;
}

function msgOKUrl(title, msg, url) {
Ext.Msg.show({
title: title,
msg: msg,
minWidth: 200,
modal: true,
icon: Ext.Msg.INFO,
buttons: Ext.Msg.OK,
fn: function(button){
if(button=='ok'){
changeUrl(url);
}
}
});
}

function msgError(title, msg){
Ext.Msg.show({
title: title,
msg: msg,
minWidth: 200,
modal: true,
icon: Ext.Msg.ERROR,
buttons: Ext.Msg.OK
});
}

Ext.onReady(function(){

var comment = new Ext.FormPanel({
labelAlign: 'top',
frame:true,
title: 'Project Reference: '+project,
bodyStyle:'padding:5px 5px 0',
width: 600,
items: [
{
xtype:'textarea',
id:'txtComment',
fieldLabel:'Comment (max 120 char):',
height:100,
anchor:'98%'
}
],
buttons:[{
text: 'Save',
handler: function(){
comment.getForm().submit({
url:'saveComment.cfm',
params: {
project: project
},
waitMsg:'Saving Data...',
success: function(fp, o){
url = "comment.cfm?project=" + project;
msgOKUrl('Success', 'Comment saved', url);
},
failure: function(fp, o){
msgError('Error', 'A problem occured while saving the comment');
}
});
}
}]
});

Condor
23 Nov 2010, 1:37 AM
I assume it's because your server is returning invalid JSON (trailing comma?).

marxan
23 Nov 2010, 1:39 AM
I don't use any Json for this page. My save method is just a cfm page with a query.

Condor
23 Nov 2010, 1:40 AM
'saveComment.cfm' should be returning {success:true} (which is JSON!).

marxan
23 Nov 2010, 2:13 AM
Indeed, that was the problem, I've put a bloody tag <html><body> in saveComment.cfm!
Thanks a lot Condor, each time I have a problem you're always the one to give me the tips to solve it!