• 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();
        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);              
        error: function (request, status, error) {

Open in new window

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

        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

Robb Hill
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

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