unable to pass null value in json


        var Arr = new Array()
        var Selected = null;
        if ($('#chk').is(':checked')) {
            var List = $('#sellist option:selected');
            $.each(List, function(index, item) {
            Selected = Arr.join(',');

I have to pass Selected as a json parameter.When check box is checked Arr is not null so code work fine but when Arr is null or empty i am unable to pass as a parameter. I use "" instead of null but unable to solve the problem. How to handle this type of situation. Thanks.


I don't understend where is the problem, becuase if i do:

var Selected = null;
var object = { selected: Selected};

i have no error, i have just an object with a property that has a null vale. Maybe you are doing something wrong when you create your object or maybe i am missing something.

EDIT - if the problem is the you must send it through ajax afterwards you can simply skip the parameter if is null an then check if the parameters exist server side or you could assign it the value false

You need to pre-select the select box first before you get a value from the $('#sellist option:selected'); selector. You may insert it before the var List = $('#sellist option:selected'); code. `

Need Your Help

How to create own and fancy \sub<float> command

latex label counter caption subfigure

I'm using packages subfigure and float to create figures and tables that I want to create and I'm trying to create my own environment graph with its own counter and caption (solved there, thanks to

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.