There is one form with a textbox id="name" and a button.
After the user clicks the button, I want to execute the $.get() to capture the reply. (I got the .click() correctly so far)
How to I 开发者_如何学Pythonpass the value the user enters to the text box as the {data} parameter in the get function?
Thank you!
You can do like:
$('.button_class').click(function(){
var val = $('#name').val();
$.get('example.php', {name: val}, function(data) {
alert(data);
});
});
$.get("user_clicked_handler.php", { name: $("#name").val() },
function(data){
alert("Data Loaded: " + data);
});
Calling $("#name").val() returns value of input box.
This Stack Overflow page was the first thing that came up on Google.
jQuery has a page about the val() method.
The data is stored in $("input#name").val();
加载中,请稍侯......
精彩评论