0

I'm loading the information from a SQL database and I have a stored procedure, so I need a method to load.

This is my controller

[HttpPost]
public IActionResult Verificar(string correoPropietario)
{
    var verificarCorreo = _PropiedadesData.Verificar(correoPropietario);

    return Json(verificarCorreo);
}

How can I get back from the AJAX?

This is my AJAX call:

<script>
    $(function(){
        var url =  '/Propiedades/Verificar'; 
        var correo = $('#correo')

        var data = {correoPropietario: correo}

        $.post(url,data).donde(function(data){})
    })
</script>
3
  • Cold you please have a look here in the example if that works for you? Commented Mar 1, 2023 at 0:59
  • donde -> done Commented Mar 1, 2023 at 6:35
  • You're also POSTing a complete jquery object, which makes no sense - perhaps you meant var data = {correoPropietario: correo.val()} (depending on what #correo actually is as you've not provided it). Commented Mar 1, 2023 at 6:37

1 Answer 1

0

how can I get back from the AJAX, this is my AJAX

You could send request to your contrroller and then can read the response what your controller returns.

I have checked your ajax code snippet and found a issue where you have used $.post(url,data).donde(function(data){}) which is incorrect.

In ajax nothing as donde which I am assuming a typos. The correct way you could refer as following:

Ajax Request Format:

HTML:

<strong><span id="appendHere"></span></strong></>
<hr />
<button type="button" name="submitButton" value="Edit" class="btn btn-primary form-control"
        onclick="GetAjaxResponse()">
    Submit Request
</button>

Javascript:

@section scripts {
    <script>
        function GetAjaxResponse() {
            var url = 'http://localhost:5094/YourController Name/Verificar';
            var correo = "Kiron";
            $.post(url, { correoPropietario: correo }, function (result) {
                alert("Response");
                console.log(result);
                $("#appendHere").html(result);
            });
        }
    </script>
}

Note: Point you should remember here, you would need to read function(result) where you will get your controller response data.

Output:

enter image description here

Note: If you would like to know more details on it you could check more sample here.

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.