When ever I pass a value from a form using submit to a php file using load, $.get or post and try to receive data or load it in general as shown below, I just get ruturned a null or undefined value. Anyone know what im doing wrong ?
iNDEX.HTML
`
<script type = "text/javascript">
$(document).ready(function(){
$("#NewOrgForm").submit(function(){
var name = $("#companyname").val();
$(".content").load("NewEntry.php",{Name: name});
});
});
</script>
<form id="NewOrgForm">
<p> Name: <input type="text" id="companyname" value="" /> </p>
<p> <input type="submit" value="Submit New Entry" id="submit" /> </p>
</form>
NEWENTRY.PHP
<?php
$companyname = $_POST['Name'];
echo $companyname;
?>
`
From some of the comments you posted it looks to me like you are incorrectly collecting data from the form. Have you tried making an alert to see if the name variable is actually set? Also try using firebug or something to see the exact URL you’re loading.
Perhaps try using a directly passed event reference to the function and fetch the fields from there instead of using an absolute selector. Might help.