Filed and fixed: http://dev.jquery.com/ticket/5794

Thanks for the test case and proposed solution!

--John



On Wed, Jan 13, 2010 at 5:05 AM, Nicolas <nico...@meilleursagents.com> wrote:
> Hello,
>
> A call to $.ajax() with a null parameter value raise an exception
> "object is null" in the $.each function, line #519.
> The stack shows that the .each() function is called from buildParams()
> function, line 5157.
>
> Here is a small testcase to reproduce the behavior:
>
> <!DOCTYPE html>
> <html>
>        <head>
>                <title>Ajax with null param value</title>
>                <script type="text/javascript" src="http://code.jquery.com/
> jquery-1.4rc1.js"></script>
>                <script type="text/javascript">
>                        $(document).ready(function() {
>                                $('#process').click(function() {
>                                        $.ajax({ url: location.href, data: { 
> param1: null }});
>                                });
>                        });
>                </script>
>        </head>
>        <body>
>                <input type="button" id="process" value="Process" />
>        </body>
> </html>
>
> This can be fixed by checking for obj null-ness in the buildParams
> function, line #5177:
>
> 5174.                                           }
> 5175.                                   });
> 5176.
> 5177.---                                } else if ( !traditional && typeof 
> obj === "object" ) {
> 5177.+++                                } else if ( !traditional && obj !== 
> null && typeof obj ===
> "object" ) {
> 5178.                                   // Serialize object item.
> 5179.                                   jQuery.each( obj, function( k, v ) {
>
> Since (typeof null === "object") in browsers I tested (ie6, ie8,
> firefox3.5, safari4, chrome 4).
> Don't know if this fix is correct though, just trying :)
>
> Many thanks!
>
> Nicolas
>
> --
> You received this message because you are subscribed to the Google Groups 
> "jQuery Development" group.
> To post to this group, send email to jquery-...@googlegroups.com.
> To unsubscribe from this group, send email to 
> jquery-dev+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/jquery-dev?hl=en.
>
>
>
>
-- 
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to