0

I faced an extremely sad issue with JSON parameters and honestly don't know how to resolve it.

I have an ASP.NET MVC 3 application, with JQuery on client side. On MVC side I have the following code:

    [HttpPost]
    public void SearchAsync(ServerRequest request)
    {
        ....
    }

    public JsonResult SearchCompleted()
    {
        ....
    }

On client side, in turn, I have the following code:

function doSearch() {

    var page = 1;
    var startDate = $("#startdate-picker").val();
    var endDate = $("#enddate-picker").val();
    var sortingColumn = "Id";
    var type = $("#ordertype-selector").val();
    var user = $("#user-selector").val();

    var request = { Page: page, StartDate: startDate, EndDate: endDate, SortAspect: sortingColumn, OrderType: type, User: user };

    var requestToPost = JSON.stringify(request);

    $("#info-message").show();
    $("#content-table-body").hide();
    $("#page-bar").hide();

    $.post("/Common/Search",
        requestToPost,
        function (data) {
            if (data.Collection) {
                $("#info-message").hide();
                          ...
                }, 500);
            }
        }, "json");
    };

I have a breakpoint on SearchAsync method and when the executing is bumping on it, there is data on request. ServerRequest is marked as [Serializable] and JsonValueProviderFactory is attached to the factories collection.

Does anyone know how can I solve this issue?

7
  • You know public void SearchAsync won't return any JSON back to your page, right? Commented Jul 25, 2011 at 13:16
  • 2Joey: Sure. This class is derived from AsyncController. Some sort of long-polling implementation. Commented Jul 25, 2011 at 13:22
  • 2ek_ny: I'm trying to pass some data to the parameter, but getting nothing. Bunch of default values, you know. Commented Jul 25, 2011 at 13:23
  • is your path in $.post correct? i think it should be /common/SearchCompleted Commented Jul 25, 2011 at 13:33
  • also you are sending data in your post request and in your action SearchCompleted() doesnot expect any value ? Commented Jul 25, 2011 at 13:33

1 Answer 1

1

The removing of *.stringify() method solved this issue.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.