JS script sending POST data in IE8

The question was asked: 49 years 9 months ago   views: 13

Good day gentlemen

Use one design has already been PTS. long

// html <a style="{cursor:pointer}" id="123">Link1</a> // just below the block in which the content varies depending on the passed id <div id="text"></div> // js code. just below on the same page <script type="text/javascript"> $(document).ready(function () { $("a").click(function() { var id = $(this).attr('id'); if(id != 'goTop'){ $.ajax({ url: "page.php", type: "POST", data: {id: id}, success: function(text) { $("#text").html(text); } }); } }); }); </script> // page page.php accepts the data, digests, and if necessary, outputs the result in a div on the page <div id="text"></div>

The data page transmitted, but in IE 8 in the block is not updated. Can anyone suggest how to write this code that would work on IE 8 too ?

p.s. discussed a slightly different upgrades of the same script, are satisfied, but not in IE . one , two

p.p.s. because the number of comments is limited, I have something to clarify

id tried to write not a number. doesn't help

<div id="text"><? //include page.php ?></div>

in the most page.php just the conclusion, if you have passed the post, display it. everything is very simple.

Any obvious mistakes there, if you all showed as is. Should work. So far, only one issue is ripe - how do you cancel a click event on the link? - 14-01-2013 в 13:28:15
usually for use. numbers in the id, I add the prefix. Very convenient to edit the data associated with the database - 14-01-2013 в 13:45:45
@mixalef, the Bug is somewhere else. Let's get a little more detail and to check even the little things. Review the generated code of the page. There are no duplicate id elements? Which version of the library?
is added dynamically or is static? PS try the following: find the closest static parent element of a link (for testing, document or even body work). The link itself - a thread of class "your_class" And semenaite code like this: $("parent_block_selector").on('click','a.your_class',function() { // here - as it was } - 14-01-2013 в 14:15:47
But if instead of $("#text").html(text); to insert alert(text); what happens? - 14-01-2013 в 14:44:54
Opera if the alert was given code page (which is needed). IE gave "undefinded". now try to copy the code to a test hosting - 14-01-2013 в 14:49:54

Answers   1

  1. replace the line:

    $("a").click(function() { // the following $("parent_block_selector").on('click','a.your_class',function() { Instead of **parent_block_selector** - selector to the parent unit for the link.
  2. Cons and banning when the links are off topic, when they lead to obscure resources when it's spam, etc.)) Lay only otnosyaschiesya to the Internet and link here in the comments.

UPD about dataType - see here

Answered: 14-01-2013 в 14:45:05