Jump to content

Need help reading a variable from AJAX


coder71

Recommended Posts

I have a PHP page that makes a checkbox appear after a certain textbox is exited. This part of the functionality is working - the user leaves the textbox, the AJAX call is made, and if certain criteria are met, the checkbox appears or it doesn't.

 

Here's where I need help. When the checkbox appears on the form and the form is submitted via POST, I can't get its value. Here's the code that's in the HEAD section:

<script type="text/javascript">
$(document).ready(function() {
	$('#id2').blur(function(){
      $.post("biz/add_official.php", {
        id1: $('#id1').val(),
        id2: $('#id2').val()
      }, function(response){
        $('#usernameResult').fadeOut();
        setTimeout("finishAjax('usernameResult', '"+escape(response)+"')", 400);
      });
    	return false;
	});
});

function finishAjax(id, response) {
 /* $('#usernameLoading').hide();*/
  $('#'+id).html(unescape(response));
  $('#'+id).fadeIn();
} //finishAjax
</script>

And here's the code that's in the FORM section:

<span id="usernameResult" style="color:green;"></span>
<script>
$('.container').find('.checkOfficial input[type="checkbox"]').val()
</script>

When the form is submitted via POST, how do I see if checkbox was checked or unchecked?

Both of these variables appear empty when the form is submitted: $_POST['checkOfficial'] $_POST['usernameResult']

Link to comment
https://forums.phpfreaks.com/topic/288819-need-help-reading-a-variable-from-ajax/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.