1

I have asp.net mvc application. i want to configure the object in jquery and want to pass it to the the action of controller . where as in my script i am using this for configure data for the ajax call:

var arr=new Array();

arr.Push(0)=1;
arr.Push(1)=2;
arr.Push(2)=3;

var  peform = {
                 EmpId: eId,
                 DepatrmentId:deptId,
                 EmpAddress:strAddress,
                 EmpBirthDate:bDate,
                 EmpAccountsId:arr
              };  

I am able to get the values in param here but. when I am trying this:

if(peform!=null)
            { 
                 var json = $.toJSON(peform);

                 $.ajax({
                 url: '/Load/SaveData',
                 type: 'POST',
                 dataType: 'json',
                 data: json,
                 contentType: 'application/json; charset=utf-8',
                 success: function (data) {

                }
        });
   }

it does not calls to action in controller. i think here :

 var json = $.toJSON(peform);

is not working as expect. is it need to add any js file to reference ? or mistake in syntax? Or please suggest me any other remedy.

3
  • Can you put an alert(json); after that line and see what it outputs? Does it look correct? Have you included jquery? Commented Feb 9, 2011 at 8:37
  • What is your controller action defined as? Could you post the method signature? Thanks! Commented Feb 9, 2011 at 8:38
  • i tried alert before and after of the line , but i getting the alert which put before. but after is not executing. so i concluded that line is not working Commented Feb 9, 2011 at 9:00

1 Answer 1

2

Try the following instead:

var json = JSON.stringify(peform);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.