• Status: Solved
  • Priority: High
  • Security: Private
  • Views: 56
  • Last Modified:

jquery syntax error on Ajax call to mvc controller

I am trying to make an ajax  call...that will grab the values off the page...and then pass those values in the URL to the controller.

Here is the ajax...its crapping out on the 2nd line starting with var allocation.

function UpdateContactEntity(clientxcontactId) {
    var allocation = $("#txtallocation" + clientxcontactId + ).val();
    alert(allocation);       
   $.ajax({
        alert("test");
        url: "/Contact.mvc/UpdateContactEntity?clientxcontactId=" + clientxcontactId + "?allocation=" +  allocation,
        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


For greater detail here is the other parts of my code:
Here is where I call it.

     [System.Web.Mvc.HttpGet]
        public JsonResult UpdateContactEntity(string data,int allocation)
        {
            var result = true;
            int clientxcontactId = data.ToInt32();
            IContactEntityEditService contactEntityEditService = DependencyResolver.Current.GetService<IContactEntityEditService>();

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

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

Open in new window

0
Robb Hill
Asked:
Robb Hill
1 Solution
 
zephyr_hex (Megan)DeveloperCommented:
You don't need to concat the close parenthesis.

Change this:

var allocation = $("#txtallocation" + clientxcontactId + ).val();

Open in new window


to this:
var allocation = $("#txtallocation" + clientxcontactId).val();

Open in new window

0
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.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now