Rio
Rio

Reputation: 14882

jQuery POST/AJAX not showing up in IE, works in FF

I've done my homework and scoured SO to no avail. I've even gone from $.post to $.ajax in an effort to clean out everything. There's no cacheing either.

$('#send').click(function() {
     $.ajax({
        url: "submit.php?ts="+new Date().getMilliseconds(),
        cache: false,
        type: 'POST',
        dataType: 'text',
        data: $("#myform").serialize(), 
        success: function(data){
                $('#myspan').html(data);
        }
        });
   });

The form looks like:

<span name="loading" id="loading"></span>
<div id="myspan"></div>
<form onsubmit="return false;" method="post" action="#" name="myform" id="myform">

etc...

What am I doing wrong? This works marvelously in Firefox but nothing happens in IE. The really weird part is that an alert(data) will show the right content in the alert box in IE. The "myspan" div doesn't have any styling or CSS to it either.

Upvotes: 0

Views: 1257

Answers (3)

Rio
Rio

Reputation: 14882

The problem was that the

<span name="loading" id="loading"></span>
<div id="myspan"></div>

were placed within a <table> tag.

Stupid IE.

grr.

Upvotes: 1

czarchaic
czarchaic

Reputation: 6318

I'm assuming you have a submit button #send inside the form?

How about trying

var form=$('form#myform').submit(function(){
  //ajax, update html
  return false;
});
$('#send').click(function(){
  form.submit();
  return false;
});

Upvotes: 0

kgiannakakis
kgiannakakis

Reputation: 104178

It seems you are expecting a plain string as response: dataType: 'text'. Are you sure that this is what you are returning and that you also send the appropriate header (content-type: 'text/plain')

Upvotes: 0

Related Questions