Forum


10:41

08/09/2008

Hi. I am getting some trouble with the response usign atferSubmit event.
I response from my servlet an objectlike
{ status:"false", message:"Banco ya existe"}
My afterSubmit is
afterSubmit: function(serverStatus, aPostData) {
var respuesta = serverStatus.responseText;
}
but I am getting an error :ret is undefined[Image Can Not Be Found]if(ret[0]==false){$("#FormError>td","#"+...erEdit)$($t).setSelection(postdata.id);}
Any Help ?
03:21

Moderators
30/10/2007

Hello,
Could you please post your code. This event in all cases should return
a array instead of result - i.e.
if(some condition) {
return [true,"",""];
} else {
return [false,"Message",""]
}
Regards
Tony
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
07:26

08/09/2008

Tony, I build my returned string as :
sb.append( "[{status:\\"").append(BooleanUtils.toStringTrueFalse(this.isStatus()));
sb.append("\\", message:\\"").append(this.getMsg().trim());
sb.append("\\"}]");
try {
response.setContentType("text/plain");
PrintWriter out = response.getWriter();
out.print(sb.toString());
out.flush();
out.close();
} catch (Exception ex) {
ex.printStackTrace();
}
It is the same code that i used to return json data to be shown in the grid...
10:14

08/09/2008

Now I am returning [false,"Banco ya existe",""]
But still got the same error message:
ret is undefined
complete()()grid.for...it-min.js (line 18)
complete()jquery-1....6.min.js (line 29)
handleError()()jquery-1....6.min.js (line 29)
[Break on this error] if(ret[0]==false){$("#FormError>td","#"+...erEdit)$($t).setSelection(postdata.id);}
I think that the error is what I need to pass something in the aPostdata array because I think if the first element in the response it is false, the code needs to show the field with error.
Am I right ? If so, how I pass an array in aPostData ?
11:47

Moderators
30/10/2007

Hello,
You should not compare this way
if(ret[0]==false) since this is internal array instead use this
afterSubmit: function(serverStatus, aPostData){
var respuesta = serverStatus.responseText;
var mydata = eval("("+respuesta+")") ;
if (mydata[status] == false) { // or mybe mydata[status] == 'false'
...
return [false,mydata[message],""];
else { return [true,"",""]; }
}
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
10:54

Moderators
30/10/2007

Hello,
As I explain in my previous post the afterSubmit function should return
certain values. Just try this
afterSubmit: function(serverStatus, aPostData) {
var respuesta = serverStatus.responseText;
return [false,respuesta,""];
}
For professional UI suites for Java Script and PHP visit us at our commercial products site - guriddo.net - by the very same guys that created jqGrid.
Most Users Ever Online: 715
Currently Online:
101 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66