开发者

Internet Explorer $.ajax() Won't Load

I am creating a page which loads HTML into a container via an $.ajax() request. This works perfectly under Firefox (long live Firefox!), IE does not load the external content. Here is a snippet of my code, could you tell me where I am going wrong?

$.ajax({
  'type' : 'GET',
  'url' : 'page.php',
  'success' : function(data) {
  //If valid data is returned...
    if (data !== '') {
      $(开发者_开发问答'div#form').html(data);
    } else {
      alert('Data way empty!');
    }
  }
});

Thank you for your time,

spryno724


Could be the missing quote at the start of 'type'. If you get a character wrong, all the other browsers may tend to gloss over it, but ie will choke.


Well I finally found an answer. I was a problem with IE's ability to insert with jQuery's .html() method. Here is the working code, in both IE and Firefox:

$.ajax({
  'type' : 'GET',
  'url' : 'page.php',
  'success' : function(data) {
    $('div#form')[0].innerHTML = data;
  }
});

Hope that helps someone,
spryno724


Here is the incoming HTML. I don't see anything invalid in there:

<form name="register" method="post" id="validate" action="/biomed-ed/users/register.htm?step=true&_=1302494250437">
<table align="center">
<tr>
<td width="200" align="right">First name</td>
<td width="600"><div class="glowBox">
<input type="text" name="firstName" id="firstName" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Enter your first name", "empty" : "We need your first name"}'>Enter your first name</span></div></td>
</tr>

<tr>
<td width="200" align="right">Last name</td>
<td width="200"><div class="glowBox">
<input type="text" name="lastName" id="lastName" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Enter your last name", "empty" : "We need your last name"}'>Enter your last name</span></div></td>
</tr>

<tr>
<td width="200" align="right">Username</td>
<td width="200"><div class="glowBox custom noHide">
<input type="text" name="userName" id="userName" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Username must be unique", "empty" : "Please provide a username", "valid" : "This name is avaliable", "invalid" : "Sorry, this name is taken"}'>Username must be unique</span></div></td>
</tr>

<tr>
<td width="200" align="right">Password</td>
<td width="200"><div class="glowBox custom">
<input type="password" name="passWord" id="passWord" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "6 characters or more!", "empty" : "You will need a password", "valid" : "Good password!", "invalid" : "Too short"}'>6 characters or more!</span></div></td>
</tr>

<tr class="spacer">
<td width="200"></td>
<td width="200"></td>
</tr>

<tr>
<td width="200" align="right">Primary Email Address</td>
<td width="200"><div class="glowBox custom">
<input type="text" name="primaryEmail" id="primaryEmail" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Enter your email address", "empty" : "An email is required", "valid" : "Email is valid" ,"invalid" : "Invalid email address"}'>Enter your email address</span></div></td>
</tr>

<tr>
<td width="200" align="right">Secondary Email Address</td>
<td width="200"><div class="glowBox custom optional">
<input type="text" name="secondaryEmail" id="secondaryEmail" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Enter your email address", "valid" : "Email is valid" ,"invalid" : "Invalid email address"}'>Only if you have one</span></div></td>
</tr>

<tr>
<td width="200" align="right">Tertiary Email Address</td>
<td width="200"><div class="glowBox custom optional">
<input type="text" name="tertiaryEmail" id="tertiaryEmail" size="50" autocomplete="off" spellcheck="true" class="validate[required]" />
<span class="tip" id='{"revert" : "Enter your email address", "valid" : "Email is valid" ,"invalid" : "Invalid email address"}'>Only if you have one</span></div></td>
</tr>

<tr>
<td width="200" align="right"></td>
<td width="200">
<input type="button" name="submit" id="submit" value="Next Step"">
</td>
</tr>
</table>
</div>
</form>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜