Reputation: 69
On my website I have a popup which is triggered by button click and which works fine. This popup features a sign up form and the following js:
<script type="text/javascript">
<!--
jQuery(function () {
jQuery("input#submit").click(function () {
jQuery('#response p').empty().append("<img src='ajax-loader.gif' />");
var name = jQuery("#name").val();
var email = jQuery("#email").val();
var dataString = '&name=' + name + '&email=' + email;
jQuery.ajax({
url: "popupmailer.php",
data: dataString,
type: "GET",
success: function (responseText) {
jQuery('#response p').empty().append(responseText);
}
});
return false;
});
});
-->
</script>
This seems to work fine, however once I try this in IE the popup does not show up at all. I've tried to troubleshoot this a little bit and once I remove the above mentioned code the popup shows up again in IE.
Is someone able to help me and determine what is wrong here in order to make this work? Thank you.
Upvotes: 0
Views: 101
Reputation: 74738
You should try with form submit
<script type="text/javascript">
jQuery(function () {
jQuery("form").submit(function (e) {
jQuery('#response p').empty().append("<img src='ajax-loader.gif' />");
var dataString = $('form').serialize(); //<---just serialize the form this will make a dataString you want.
jQuery.ajax({
url: "popupmailer.php",
data: dataString,
type: "GET",
success: function (responseText) {
jQuery('#response p').html(responseText); //<--use .html() here
}
});
return false;
});
});
</script>
Upvotes: 1
Reputation: 2562
try this
jQuery('#response p').empty().html(responseText);
instead of
jQuery('#response p').empty().append(responseText);
Upvotes: 0