Quantcast
Channel: Developer to developer
Viewing all articles
Browse latest Browse all 9076

Calling an Block Controller from Ajax

$
0
0

Hello Folks

I'm trying to call a controller with ajax and it keeps on failing. Anybody can help? Here is the code

Controller Code

public class JumbotronConversionBlockController : BlockController<JumbotronConversionBlock>
    {
....
        [HttpPost]
        public ActionResult Convert(string a)
        {
            return Json("Hello its working!");
        }
....

Html Code

...
            function clickSubmit() {
                $.ajax({
                    type: "POST",
                    url: '@Url.Action("Convert", "JumbotronConversionBlockController")',
                    contentType: "application/json; charset=utf-8",
                    data: { a: "testing" },
                    dataType: "json",
                    success: function() { alert('Success'); },
                    error: function () { alert('Failed'); }
                });
            }
...

ERROR

  1. Request URL:
    https://local.me.com/rendering/JumbotronConversionBlockController/Convert
  2. Request Method:
    POST
  3. Status Code:
    404
  4. Remote Address:
    127.0.0.1:443


Viewing all articles
Browse latest Browse all 9076

Trending Articles