传递给servlet时更改td的值

时间:2014-07-31 04:57:16

标签: javascript jquery servlets

我循环到一个表,并给他们名字或ID,但当我需要从

获取一个值时
<select>
<option>Yes</option>
<option>No</option>
</select>

var $tds = $(this).find('td select');
$tds.eq(0).prop('name','support' + ctr);

if($tds.val() == "Yes"){
// I want the value to pass in servlet is true else false but dont know the right syntax
}

1 个答案:

答案 0 :(得分:0)

结帐http://api.jquery.com/jquery.ajax/

构建代码:

if($tds.val() == "Yes"){
  // Initialize an ajax POST request to servlet some.php with someData
  $.ajax({
    type: "POST",
    url: "some.php",
    data: someData // Put your data here
  })
  // When done, alert a message indicating the data was saved.
  .done(function( msg ) {
    alert( "Data Saved: " + msg );
  });
}

您还可以捕获并处理向servlet发出请求时可能出现的错误。