Hi.
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

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

                $.ajax({
                    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);
                    }
                });
            });
        });
<script>

method abrir inside prescaviController

<HttpPost>
        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, networking, learning, and sharing knowledge.