[ACCEPTED]-jQuery post parameter to load-load
Accepted answer
$(document).ready(function() {
$("#add").click(function() {
$("#result").load("add.php", {
name: $("#txtname").val(),
tel: $("#tel").val()
});
});
});
0
I've found a good way to do this - use serializeArray() for 3 the data part, if you are pulling from a 2 form and still want to use .load(). It may 1 save you some extra work.
var form_data = $('#my-form').serializeArray();
$('.my-container').load('/myurl/', form_data);
$('.element').load('page.php', {var1:'value1', var2:'value2'}, function() {
// actions after load page (optional)
});
0
$(document).ready(function(){
$("#add").click(function(){
$("#result").load("add.php", {
'name': $("#txtname").val(),
'telephone': $("#tel").val()
});
});
});
0
You can also wrap your inputs into a form
<form action="add.php" method="GET" id="my_form">
<p>Name:<input type="text" name="name" value="" id="txtname" /></p>
<p>Telephone:<input type="text" name="tel" id="tel" value="" /></p>
<input type="button" value="Submit" id="add" />
</form>
So 1 you can easily maintain your parameters
$(document).ready(function() {
$("#add").click(function() {
$("#result").load(
$("my_form").attr('action')
, $("my_form").serialize()
});
});
});
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.