Ajax code not work in Internet Explorer

Hi E's, I have a part of my code does not work in Internet Explorer (tested with version 11), but work in major browsers like Firefox, chrome or safari.
This is the code:
    $.ajax({
    method:"POST",
    url:"processa.php",
    data:{"nj":numero_jogo, "fase":'3'},
    success:function(data, textStatus, jqXHR){},
    error:function(jqXHR, textStatus, errorThrown) { coneccao('1'); },
    });

Open in new window

I believe the reason for not work was this lines:
    success:function(data, textStatus, jqXHR){},
    error:function(jqXHR, textStatus, errorThrown) { coneccao('1'); },

Open in new window

Note:I got the code here in this question:http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/Q_28037240.html
What I have to do for this code work in i.e.?

The best regards, JC
LVL 3
Pedro ChagasWebmasterAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Slick812Connect With a Mentor Commented:
hello Pedro Chagas, ? ? It does seem odd that it works the first time and not after that?
I see some things I would change in the code.
In my browser if I place " around the object property names it kills my javascript

$.ajax({
    method:"POST",
    url:"processa.php",
    data:{nj:numero_jogo, fase:"3"}, // DO NOT place " on the property Name
    success:function(data){},// don't use param, don't call
    error:function(jqXHR, textStatus, errorThrown) { coneccao('1'); }
// remove the comma here
    });

the IE ver 11 is NEW, so I would use the NEWEST version of jquery which is -
jquery/1.11.0

It helps me greatly in jquery ajax to separate the parts of the ajax, instead of mashing them all together, I can understand and debug it better like this
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
//
//
var ajxOptions = {
    url: "ajax_prev.php",
    type: "POST",
    data: {nj:numero_jogo, fase:"3"},
    dataType: "text",
    timeout: 3500}

var aj = $.ajax(ajxOptions);

aj.done(function( received ) {// success
    $('#ajaxRe').html(received);
	});

aj.fail(function(xhr, error1, err) { //error
  coneccao("1"); });

Open in new window

But it is difficult to debug code if it works sometimes and then don't
0
 
GaryCommented:
Code looks fine bar the extraneous comma at the end of the error line.
What's the error message?
0
 
Pedro ChagasWebmasterAuthor Commented:
Hi Gary, I never inspect code in i.e., usually I use Firebug in FF.
What is the best software like firebug for i.e..
I have to see the error message!
Thank you.

~JC
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Pedro ChagasWebmasterAuthor Commented:
Forget, it is F12.
0
 
leakim971PluritechnicianCommented:
You can use fiddler to check the data
Any trailing comma at the end?
0
 
Pedro ChagasWebmasterAuthor Commented:
Hi, I did some tests, and the problem is, that code in i.e. just work in the first request, if I repeat the request the php don't receive any information.
It's weird, because in the other major browsers the same project/code works.

~JC
0
 
Pedro ChagasWebmasterAuthor Commented:
Hi again, I use fiddler, and when I execute the first time the code the ajax made the request successful. When I try use again the code, fiddler don't show anything, no error, nothing.
In the attach image, you can see the information about the first request, maybe contain some important information:the first request
-JC
0
 
GaryCommented:
Try accessing the url directly and see if you get an error, it's sometimes easier to debug than debugging an ajax call.
0
 
Pedro ChagasWebmasterAuthor Commented:
No php errors.

~JC
0
 
GaryCommented:
Can you put a test page online?
0
 
Pedro ChagasWebmasterAuthor Commented:
Hi, I will show you the project, maybe in that way one of you can help me:
This is the project: http://rdsrc.us/zufBE0
If you check the source code, between lines 1783 - 1840 you can see entire script and there are 48 blocks of the same code, each block each piece of puzzle.
The problem occurs when you start the game, and for each peace you move I do that Ajax call.
One important note, I created the JavaScript code from php, like this:
function codigo_jquery ($valor){
$code= '
        var movimento'.$valor.';
        $("#pecas'.$valor.'").click(function(){
        if(controlo == 0 && controlo != 2 && movimento'.$valor.' != 3){
        controlo = 1;
        var mede = $("#pecas'.$valor.'");
        actualleft = mede.position().left;
        var newleft = actualleft;
        if(EmEscuro == 0){
        newleft = newleft + 30;
        } else {
        newleft = newleft + 60;
        }
        newleft = newleft + "px";
        actualtop = mede.position().top;
        var newtop = actualtop;
        newtop = newtop + 10;
        newtop = newtop + "px";
        $("#selector_verde").css({"top": newtop, "left": newleft});
        $("#selector_verde").css("visibility", "visible");
        select = "#pecas'.$valor.'";
            } else if (controlo == 1 && select == "#pecas'.$valor.'" && controlo != 2 && movimento'.$valor.' != 3){
                $("#selector_verde").css("visibility", "hidden");
                controlo = 0;
                    } else if (controlo == 1 && controlo != 2 && movimento'.$valor.' != 3){
                        var nome_select;
                        movimento'.$valor.' = 3;
                        var nome_select = select.replace("#pecas", "");
                        window["movimento" + nome_select] = 3;    
                        $("#pecas'.$valor.'").css("z-index", zindex);
                        $(select).css("z-index", zindex);
                        zindex++;
                        var mede = $("#pecas'.$valor.'");
                        llleft = mede.position().left;
                        tttop = mede.position().top;
                        $("#selector_verde").css("visibility", "hidden");
                        $("#pecas'.$valor.'").animate({
                        left: actualleft, top: actualtop}, 500, function(){
                        movimento'.$valor.' = 0;
                        });
                        $(select).animate({
                        left: llleft, top: tttop}, 500, function(){
                        window["movimento" + nome_select] = 0;
                        });
                        controlo = 0;
                        n_jogadas++;
                        if(n_jogadas == 15){
                        numero_jogadas_interaccao();
                        }
                        console.log(n_jogadas);                                             
                        $.ajax({
                        method:"POST",
                        url:"ajax_prev.php",
                        data:{"nj":numero_jogo, "fase":\'3\'},
                        success:function(data, textStatus, jqXHR){},
                        error:function(jqXHR, textStatus, errorThrown) { coneccao(\'1\'); },
                        });                                                                                             
                        }
        });
';

echo $code;
}
$contador = 0;
foreach($array_sequencia as $valor){
    codigo_jquery($valor);
    $contador++;
}

Open in new window

I'm getting worried, because the game runs well on all major browsers, and ie is not going well.
Another thing that makes me confused is the fact that work well on the first Ajax call, but when I move the second piece of the game (puzzle) the code no longer works, but only in ie.
If you need more information, please tell me. I appreciate your good will, and it is very important to me resolve this problem, if I have problems with i.e., the project ends.

The best regards, JC
0
 
Pedro ChagasWebmasterAuthor Commented:
To facilitate matters to us all, I wrote an example that illustrates the real example, and that also does not work in ie:
I create the index.php file, that contains the jQuery code with Ajax. Also I create the file processa.php that send a email every time the file is sought.
Every time I click in the div botao, the alert "is working" appear. In tests never detected any error, always appear the alert "is working" (sucess).
The problem is, I just receive one, just one email, if I click thousands of times, no metter, I just receive a single email, not a thousands emails as it was supposed.
Index.php:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="../../ficheiros_apoio/jquery.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="botao">here</div>
<script>
<? function codigo_jquery ($valor){
$code= '
    $("#botao").click(function(){
    var numero_jogo = 1;
    $.ajax({
    method:"POST",
    url:"processa.php",
    data:{"nj":numero_jogo, "fase":\'3\'},
    success:function(data, textStatus, jqXHR){ sucesso();},
    error:function(jqXHR, textStatus, errorThrown) { erro();},
    });
    });    
    ';

echo $code;
}
codigo_jquery("10");
    ?>
        function erro(){
        alert("not work");
            }
    
    function sucesso(){
        alert("is working");
    }
 </script>  
 </body>
 </html>

Open in new window

processa.php:
<?
mail("xxxxxxx@xxxxxxx.com", "chegou", "chegou");
?>

Open in new window

Invite to test yourselves.

The best regards, JC
0
 
Pedro ChagasWebmasterAuthor Commented:
I've requested that this question be deleted for the following reason:

HI E's, The problem was the version of jquery file, I change the file to the most recent Jquery file, and the problem was overcome. Sorry for any lost time.

The best regards, JC
0
 
Pedro ChagasWebmasterAuthor Commented:
Hello. I don't want delete the question, because while I was writing @Slick812 also is writing the solution, and therefore did not see his response.
It would be unfair to close the issue because @Slick812 gave me the solution.
Thank you for your attention.

The best regards, JC
0
 
Pedro ChagasWebmasterAuthor Commented:
The correct answer is:
<<<the IE ver 11 is NEW, so I would use the NEWEST version of jquery which is -
jquery/1.11.0>>>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.