0

I have a add button it calls the controller does what it needs to do but it never calls the success function from the chrome browser? Works in IE so I know it is getting called with another browser not sure why chrome is not working?

  $('#ui_btn_AddItem').click(function () {

//...getting the data values here....      
            $.ajax({
                url: "/userGroup/CopyItem",
                type: "POST",
                dataType: "json",
                contentType: "application/json; charset=utf-8",
                data: { "id": distribId, "selectedIDs": selectedValues },

                success: function (data) {
                    alert('success');
                    window.location(data.retUrl); // Success Callback
                },
                error: function (req, status, error) {
                    alert('error');
                    bootbox.alert(req.responseText);
                }//  error: errorCallback
            });




    });

My controller is called like [HttpPost]

      public ActionResult CopyItem(
...doing some copy stuff then returning the json result.
  return Json(new { success = true, retUrl = returnUrl }, JsonRequestBehavior.AllowGet);

not sure why my alert doesn't come up with chrome any ideas?

Patsy Issa
  • 10,623
  • 3
  • 52
  • 72
Spafa9
  • 682
  • 3
  • 13
  • 29
  • 1
    Your contentType is wrong, you're not sending json but url encoded form data. Temove contentType and the correct one will be set. See http://stackoverflow.com/questions/13735869/datatype-application-json-vs-json/13735890#13735890 – Musa Jul 24 '14 at 14:23
  • I tried removing the contentType still not getting the alert to show. I looked at the developer tools and I am getting an error under network. Uncaught TypeError: object is not a function – Spafa9 Jul 24 '14 at 14:28
  • Ok I didn't realize the page was caching now I am back to the original problem of the page not redirecting the page it gets into the success and window.location.href(data.retUrl); I am alerting the url and it give me the path of the controller and action result with the ID appended on I am wonder if chrome is caching the page basically I am calling the same page I am on because I need to refresh the page. – Spafa9 Jul 24 '14 at 14:58
  • I am an idiot I meant to call my function NavigateTo(path) – Spafa9 Jul 24 '14 at 15:04

0 Answers0