PDA

View Full Version : Ajax request is converting params with null values to empty strings



sowmyav82
22 Oct 2010, 3:42 AM
We have a scenario where one of the params of Ajax request call is null. In 2.3, the handler of the call used to get a null value. But in 3.3, the value is getting passed to the handler as an empty string.

On digging into the request call further, we realised that urlEncode method is the one responsible for the same.

Please find attached a testcase. I have two alerts in this testcase. One that shows the UrlEncode of the params with one of the parameters set to null and another based on what the handler sees.

1. Drop the folder in examples folder of ExtJS source code of 2.3. You will get an alert that shows only the non-null parameter. Parameter whose value is set to null is not passed to the handler and hence the handler sees it as a null value.
2. Drop the same folder in examples folder of 3.3. You will get an alert that shows the null parameter with empty value and non-null parameter.

Condor
22 Oct 2010, 4:17 AM
IMHO Ext 3.3 is correct. There is no way to encode a null value in an url, so an empty value is best.

Example:

AjaxTestHandler.ashx?notes=null&action=TestHandler
means the 'nodes' parameter is 'null' (string) and not null.