jimsmith
jimsmith

Reputation: 33

passing form variables through jquery .post

This is what the post looks like, I'm "printing" the return data out in the 'area' div, in that data is a hidden form variable input type='hidden' id='pc1' value='wh5', is it possible to get the value of id 'pc1'?, I get 'undefined' at the moment. Do you use live or bind? I had a look at those but they appear to be for click events.

$("#chk").click(function(){$.post("includes/mainform_new.php",{

 postcode:$("#postc").val()

},

    function(data){

        $("#area").html(data); <--- the input element pc1 is in the returned data

        alert($("#pc1").val()); <--- returns undefined

      });


});

Upvotes: 0

Views: 138

Answers (1)

Asif Mulla
Asif Mulla

Reputation: 1664

You could do this:

function(data){

        var response = $("#area").html(data); <--- the input element pc1 is in the returned data
       alert((response.find("#pc1").val())


      });

Upvotes: 1

Related Questions