Question

I'm sending a JSon to my Asp.Net MVC 3 Controller that is inside a Web Worker (using jquery-hive). At the PostMessage, I can capture a Asp.Net error telling me that it find the controller but has no action method X.

See the code: Here I call the Worker at main.js:

 var worker = new Worker('models/worker.js');

worker.onmessage = function (event) {
    var a = event;
};
worker.postMessage(null);

The code into worker.js:

  importScripts('hive.pollen.js');  $(function (msg) {
    $.ajax.get({
        url: '/Search/Method1/',
        dataType: 'POST',
        data: null,
        success: function (jsonObj) {
            $.send( jsonObj);
                }
    });
});

The controller has this method:

[HttpPost]
    public JsonResult Method1(string test)
    {
        return Json("worked! " + test);
    }

The posMessage that the worker give me back, it's a asp.net error.

[HttpException]: A public action method "Method1" was not found on controller SearchController

Was it helpful?

Solution

It seems like you are issuing a GET request ($.ajax.get method).
Try using jquery's $.post()

OTHER TIPS

You have an error on: dataType: 'POST'.

In your case, you have to put dataType: 'json' in order to send the data in the correct format

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top