When trying to pass a parameter to the mehod I get
error: not found
I've been trying other url syntaxes (@url.action) but to no avail also.

script inside input/index view

    $(document).ready(function () {
          $("#btnSubmit").click(function () {
                var presc1 = $('#p1').val();

                    type: "POST",
                    dataType: "json",
                    contentType: "application/json; charset=utf-8",
                    url: "prescavi/abrir",
                    data: "{presc1}",

                    success: function (data) {
                    alert("Success: " + success.d);
                    //call on ajax call failure
                    error: function (xhr, textStatus, error) {
                    alert("Error: " + error);

method abrir inside prescaviController

        Function abrir(param As String) As ActionResult
            ViewData("Message") = "abriu! " & param & " ."

            Return View()
        End Function

also tried to other methods of the same controller.
( Public Class prescaviController ) with and without parameters - just to check if it triggered the next action

with "../prescavi/abrir" it gives me a different error, either with or without any parameters: "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

solved it.

data: "{param:'" + presc1 + "'}",

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.