Hi guys, I'm hoping that you can help me with an intermittent issue I've been having.
I have a block of code that looks roughly like this:
- <form method="POST" id="milform" name="milform" action="^$this^">
<div>Create Military</div>
<div style="float: left; width: 500px; border: solid 1px grey;">
<div class="statuslabel">Military Name:</div>
<div class="statusfield"><input type="text" name="milname" length="32" size="32"></div>
<div class="statuslabel">Army Name:</div>
<div class="statusfield"><input type="text" name="armname" length="32" size="32"></div>
<input type="hidden" name="cmil" value="1">
</div>
<div style="float: left; width: 500px; border: solid 1px grey;">
<div><input type="submit" name="milsubmit" value=" Create" onclick="$.ajax({url: 'mil.php', type: 'POST', dataType: 'html', data: $('#milform').serialize(), success: function(html){$('#commandpane1').html(html)} }); return false;"></div>
</div>
</form>
If I use this code as written, the jquery $.ajax call serializes properly, calls the form correctly, but it doesn't pass any data through to the receiving php script; when I check the back and forth with firebug, it's reporting a GET of the script, even though I'm trying to send a POST, and no data is returned when I do a var_dump( $_POST ); If I take the {} out of the call,
- <input type="submit" name="milsubmit" value=" Create" onclick="$.ajax(url: 'mil.php', type: 'POST', dataType: 'html', data: $('#milform').serialize(), success: function(html){$('#commandpane1').html(html)} ); return false;">
it correctly passes the POST, but the ajax component doesn't work and it behaves like a regular HTML submit button. I'm at a loss, and I would really appreciate some guidance.
Thanks in advance!