0

I am having trouble with the function ShowResponse action on my Ajax Form. I am trying to show a simple message in the #show div once the form has been submitted. The Ajax submission is working okay and I can get an alert to work but I cant get the #show div to display. My code looks like this,

<script type="text/javascript" src="/uploads/JS/jquery.form.js"></script>

<script type="text/javascript"> 
$(document).ready(function() { 

var options = { 
target:        '#contact_form_94',
success:       showResponse
}; 

$('#m477famoduleform_2').ajaxForm(options); 
}); 

function showResponse(responseText, statusText, xhr, $form)  { 
    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + 
        '\n\nThe output div should have already been updated with the responseText.'); 
} 
</script> 

If anyone could help that would be great. As a minimum I would just like to replace the form with a 'Success' message.

Thanks

Chris

  • Can you use firebug or the like to see if your #show div is receiving your "responseDoc"? If it is, could it be that your div is just not visible and you need to set it's CSS display attribute? – El Guapo Aug 12 '11 at 14:30
  • make sure "#contact_form_94" element exists, may do something like $('#contact_form_94').length in success – Praveen Prasad Aug 12 '11 at 17:16

2 Answers2

0

Does it work if you include the showResponse function within the $(document).ready?

evasilchenko
  • 1,862
  • 1
  • 13
  • 26
0

If you are saying you can alert the response and can see it then I think #show does not exist on the page. Try to alert $('#show').length and see what you get.

ShankarSangoli
  • 69,612
  • 13
  • 93
  • 124