-1

I have an Ajax call, that in the Success function, load a PartialView(html), in a container.

And I need to do "something" with a hiddenField value that it is in the loaded PartialView.

Trying $("#IdOfHiddenTextField").val() or a class selector and Jquery do not select the Html element.

How can I achieve that?

Actual code:

$.ajax({
        url: '/apps/server',
        type: 'POST',
        data: formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (response) {
            if (response.ok == "ok") {
                esValido = true;
                $("#divContenedorPaso2").html(response.vistaRazor);
                if (response.modificoEmail) {
                    $("#popup-mensaje").html("Modification successfull");
                    $('#myModalAdvertencia').modal('show');
                }
            } else {
                $("#divContenedorPaso2").html(response);
            }
        }
    });

I need to do:

$.ajax({
        url: '/apps/server',
        type: 'POST',
        data: formData,
        async: false,
        cache: false,
        contentType: false,
        processData: false,
        success: function (response) {
            $("#divContenedorPaso2").html(response);

            var submitSuccesfull = $("#IdOfHiddenTextField").val();
            // this hidden element is inside de PartialView "response"

            if (submitSuccesfull ) {
                esValido = true;
                $("#popup-mensaje").html("Modification successfull");
                $('#myModalAdvertencia').modal('show');
            } else {
               esValido = true;
            }
        }
    });
Igua95
  • 5
  • 4

1 Answers1

0

I don't know your code but i think you need something like this :

$.ajax({
    url: "partialView.html", 
    success: function(response) {
        var result = $(response).find("#IdOfHiddenTextField").val();
    }
});
Jax Teller
  • 1,447
  • 2
  • 15
  • 24
  • **Thanks!** It works! Is it the only way that Jquery recognise an element, which load after the script? – Igua95 Jul 17 '18 at 14:04