Error on AJAX Call to MVC Controller

I have the following ajax call and controller.   I am getting the error message indicating
the parameters dictionary contains a null value for parameter "allocation" of non nullable type decimal for method system.web.jsonresult UpdateContactEntity(System.string, system.decimal,system.string,system.string) in contact controller.  An optional parameter but be a reference type, a nullable type, or be declared as an optional parameter.

Here is my ajax:  Note all the alerts pull a value..so this must be in the ajax call itself..perhaps with url

function UpdateContactEntity(clientxcontactId) {
    var allocation = $("#txtAllocation_" + clientxcontactId).val();  
    var role = $('#selectRole_' + clientxcontactId +' :selected').text();  
    var designate =  $('#selectDesignate_' + clientxcontactId +' :selected').text(); 
    alert(allocation); 
    alert(designate);
    alert(role);   
    alert(clientxcontactId);
   $.ajax({
        url: "/Contact.mvc/UpdateContactEntity/ " + clientxcontactId + "?allocation=" +  allocation + "?role=" +  role + "?designate=" +  designate,
        type: 'GET',
        cache: false,
        dataType: 'json',
        data: { data: clientxcontactId },
        success: function (data) {
                var result = $.trim(data.Result);              
                ShowGridRedraw();
                },
        error: function (request, status, error) {
        alert(request.responseText);
        }     
     });
}

Open in new window


And here is the call to the controller:

[System.Web.Mvc.HttpGet]
        public JsonResult UpdateContactEntity(string id, decimal allocation, string role, string designate)
        {
            var result = true;
            int clientxcontactId = id.ToInt32();

            IContactEntityEditService contactEntityEditService = DependencyResolver.Current.GetService<IContactEntityEditService>();

            var updated = contactEntityEditService.UpdateContactClient(clientxcontactId,allocation, role, designate);

            result = updated;
            return Json(result, JsonRequestBehavior.AllowGet);
        }

Open in new window

LVL 11
Robb HillSenior .Net DeveloperAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Snarf0001Commented:
Your URL construction in the ajax query is wrong.  You're appending "?" on each attribute, so the server is effectively ignoring all but the last value.
The start of the querystring has to be with "?", the rest have to be joined with "&"
1
Robb HillSenior .Net DeveloperAuthor Commented:
oh...can you show me please
0
Snarf0001Commented:
Sure, you just need to end up with something like this:

/Contact.mvc/UpdateContactEntity/123?allocation=123&role=xxx&designate=xxx

So just change the code to this:
function UpdateContactEntity(clientxcontactId) {
    var allocation = $("#txtAllocation_" + clientxcontactId).val();  
    var role = $('#selectRole_' + clientxcontactId +' :selected').text();  
    var designate =  $('#selectDesignate_' + clientxcontactId +' :selected').text(); 
    alert(allocation); 
    alert(designate);
    alert(role);   
    alert(clientxcontactId);
   $.ajax({
        url: "/Contact.mvc/UpdateContactEntity/ " + clientxcontactId + "?allocation=" +  allocation + "&role=" +  role + "&designate=" +  designate,
        type: 'GET',
        cache: false,
        dataType: 'json',
        data: { data: clientxcontactId },
        success: function (data) {
                var result = $.trim(data.Result);              
                ShowGridRedraw();
                },
        error: function (request, status, error) {
        alert(request.responseText);
        }     
     });
}

Open in new window

1

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Robb HillSenior .Net DeveloperAuthor Commented:
you are awesome..thank you
0
Robb HillSenior .Net DeveloperAuthor Commented:
Great answer ...explicit detail..thanks a bunch
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.