开发者

jQuery accessing form values in a div that has been loaded through $.ajax

I am loading a page into a div via jQuery in install1 . Now the page that install1 gives me contains a few radio buttons the likes of:

<input name="ostype" type="radio" value="solaris">
<input name="ostype" type="radio" value="windows">

Now, I am trying to access the selected value in install2 .

Here is the JavaScript code for the two functions:

function install1() {
  $("#installer").html("<div align='center'><img src='modules/servers/flosoftdedicated/images/ajax/loading-warning.gif' border='0' alt='' /><br />Loading...</div>"); 
  $.ajax({
    type: 'GET',
    url: 'clientarea.php',
    data: 'action=productdetails&id=' + $('#serverid').val() + '&modop=custom&a=installgetos&step=1',
    timeout: 10000,
    success: function(data){
        $("#installer").html(data);
        },
    });
}
function install2() {
  $("#installer").html("<div align='center'><img src='modules/servers/flosoftdedicated/images/ajax/loading-warning.gif' border='0' alt='开发者_StackOverflow社区' /><br />Loading...</div>"); 
  $.ajax({
    type: 'GET',
    url: 'clientarea.php',
    data: 'action=productdetails&id=' + $('#serverid').val() + '&modop=custom&a=installgetos&step=2&ostype=' + $("input[name='ostype']:checked").val(),
    timeout: 10000,
    success: function(data){
        $("#installer").html(data);
        },
    });
}


In your install2 function you are resetting the content of the install2 div by calling $("#installer").html("<div align='center'>... and removing the inputs.

Remove the first line in the install2 function.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜