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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.