开发者

jQuery $.post() and IE7

开发者 https://www.devze.com 2023-01-24 22:55 出处:网络
On IE7, I\'m not getting a response back from my POST: function updateItem(item) { $.post(\"updater.ph开发者_Python百科p\",{key:item.id, value:item.value},function(response) {

On IE7, I'm not getting a response back from my POST:

function updateItem(item) {
  $.post("updater.ph开发者_Python百科p",{key:item.id, value:item.value},function(response) {
    $('#response').html(response);
  });
}

<div id="response"></div>
<select id="PRIMARY_KEY" onchange="updateItem(this)">
  <option>1</option>
  <option>2</option>
</select>

<?php
  echo 'UPDATED KEY: ' . $_POST['key'] . ' TO: ' . $_POST['value'];
?>

It works with all of my other browsers. Why is that?

Edit: Initially, I was trying to answer this question.


Try this : (2 modifications : value's... value and <option value="1">1</option>)

<script>
    function updateItem(item) {
  $.post("updater.php",{key:item.id, value:item.options[item.selectedIndex].value}, function(response) {
    $('#response').html(response);   });

}
</script>
<div id="response"></div>
<select id="primary_key" onchange="updateItem(this)">
  <option value="1">1</option>
  <option value="2">2</option>
</select>

I used jsfiddle, IE7 and debugBar to find those. http://jsfiddle.net/d3xk8/


There is error in setting innerHTML through jquery.

Use document.getElementById("#response").innerHTML = response;


Usually if I don't get a response back from a function it means that I've misformatted the data I'm trying to pass. I'd recommend putting double quotes around the string that you are echoing and seeing if that works.

0

精彩评论

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