I am brand new to jquery and trying to modify a basic script from php academy.
the jquery script is:
<script type="text/javascript">
function get() {
$.post('getpeopleinjobs.php', {
postvarfname: form.firstname.value,
postvarlname: form.d = surname.value
}, function(output) {
$('#age').html(output).show();
});
}
</script>
and my form code is:
<form name="form">
<input type="text" id="firstname">
<input type="text" id="surname">
<input type="button" value="get" onclick="get();">
</form>
This worked perfectly when I was passing just one variable and my code snippet was:
$.post('getpeopleinjobs.php', {
postvarfname: form.firstname.value
}
I then tried to add a second variable with
$.post('getpeopleinjobs.php', {
postvarfname: form.firstname.value,
postvarlname: form.d = surname.value
}
It does not work now in Internet Explorer but interestingly enough it does work in Chrome?
Any advice for the beginner?=
You have the concept down correctly but there appears to be a minor mistake
//Posted Code
$.post ('getpeopleinjobs.php',{postvarfname: form.firstname.value,postvarlname: form.d=surname.value}
// Fixed Code
$.post ('getpeopleinjobs.php',{postvarfname: form.firstname.value, postvarlname: form.surname.value}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With