views:

16

answers:

1

Hi All,

i have a partial view with a form in it. It is strongly typed.

I am using ajax in a view with the partial view in it to submit the form.

It's basically a form that creates a new DB item and i can see that the controller action is working and being called.

my ajax submit looks like this:

$(document).ready(function () {
     var form = $("#addPost");
     form.submit(function () {
        $.ajax({
        type: "POST",
        url: form.attr("action"), 
        data: form.serialize(),
        dataType: "json",
        success: function (data) {
            alert('success!');
        },
        error: function (req, status, err) {
             alert('err=' + err + ' status=' + status);
        }
   });
   return false;
  });
}); 

So the controller perform the work just fine and attempts to return the strong type that the partialview is.. and i keep getting the error js alert with no info in it.

Is this because my parent view is not typed the same and it is the view that sent the ajax?

if this is so what is the solution? Am i going about this wrong? I need the parent page to get the response and then display the form info back on the page using js. thanks!

A: 

You need to display some more detail. For example, the code in the controller. Also, have you tried debugging this to see what is returned?

However, the surefire way of debugging this kind of ajax silent fail is to use Firefox and its add-in, Firebug. It will display errors and show you the response to each call to the server. If your controller is returning an error, the server will send a full error page and you can see this in Firebug.

The fact that ajax silences the call is a different matter.

On the other hand there could be a typo in your jQuery code. See:

Error in jquery code casusing problems...

awrigley