Solved

Jquery - differences between two error codes

Posted on 2014-04-01
5
446 Views
Last Modified: 2014-04-01
Hi E's,
Can you please tell me, what is the diference between this two jQuery "error:" codes:
error:function(jqXHR, textStatus, errorThrown) { alert("error"); }

Open in new window

and
error: function(){ alert("error");}

Open in new window

I try to understand the difference, because the first error not work in i.e.11, and functions are identical I can substitute one for the other.

The best regards, JC
0
Comment
Question by:Pedro Chagas
  • 3
  • 2
5 Comments
 
LVL 35

Accepted Solution

by:
Miguel Oz earned 500 total points
ID: 39970608
The difference is that you are defining the 3 parameters that provides more error details. I am assuming it is an ajax call.

Please post the whole AJAX call code. the error and what version of Jquery you are using as well. Also make sure you are not having any non-visible character that may invalidate the first error method.
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 39970707
Hi,
This code not work in i.e. 11
$.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

but this one work:
$(function(){
        $.ajax({
        type: "POST",
        url: "processa.php",
        data: {'varinha': '0'},
        success: function(dat){
                if(dat != ""){
                alert(dat);
                }
        },
        error: function(){ alert("erro");}
        
        });
});

Open in new window

The version of jQuery that I use is v1.5.2.
I know is old, but I begin the project with that version, and when I try to change to more recent version, lots of scripts not work.

~JC
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 39970711
What kind of information receive data, textStatus, jqXHR?

~JC
0
 
LVL 35

Expert Comment

by:Miguel Oz
ID: 39970752
Certainly it is an old version and it is always a risk that it may not work at all in modern browsers. Try:
$.ajax({
    type: "POST",
    url: "processa.php",
    data: {"nj": numero_jogo, "fase":'3'},
    success: function(data){ alert('success'); },
    error: function(jqXHR, textStatus, errorThrown) { alert('error'); },
    }); 

Open in new window

If it does not work:
Q1. Was the faulty code working before? Which IE version?
Q2. If it works in IE version X. Does it work in IE 11 compatible mode? You could ask your users to use IE 11 compatible mode for the time being.
0
 
LVL 3

Author Comment

by:Pedro Chagas
ID: 39970802
Thank you for your time and try to help.
I'll think seriously about changing the version of jquery. In the future I may have big problems if do not.

The best regards, JC
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now