4

JQuery with some very simple GET Method call and transfer data using the json program But constantly ran error, then IE tells me "SyntaxError"

But I have removed the data parameter is ok ...

Please help us to see in the end the problem? Thank you !!

var url = "/demo/test.do";
$.ajax({
  url: url,
  method: "GET",
  dataType: "json",
  data: jQuery.parseJSON('[{"dispatch" : "add"}]'),
  success: function(data) {
      alert(data);
  },
  error: function(jqXHR, textStatus, errorThrown) {
      console.log(errorThrown);
  }
});
陳若天
  • 41
  • 2
  • Console.log() does not work in IE. see http://stackoverflow.com/questions/14086675/which-browsers-support-console-log – RN Kushwaha Apr 22 '15 at 04:55
  • https://developer.mozilla.org/en-US/docs/Web/API/Console/log -- Though you can add a super-basic shim: `if (typeof console==='undefined'){console={log:function(){}};}` -- that will make a fake console for browsers that don't support it. Speaking best-practice wise, you should not have any use of console.log in live code, or use that shim. For development, it's okay. – Chris Baker Apr 22 '15 at 06:03

2 Answers2

1

IE and console.log has issues unless ie8 has Dev tools enabled.

asdf
  • 899
  • 1
  • 6
  • 10
0

Give this a try. No need to try to parse the JSON for the input.

 var url = "/demo/test.do";
 $.ajax({
   url: url,
   method: "GET",
   dataType: "json",
   data: {
       "dispatch" : "add"
   },
  success: function(data) {
      alert(data);
  },
  error: function(jqXHR, textStatus, errorThrown) {
      console.log(errorThrown);
  }
});
Bob Tate
  • 1,381
  • 9
  • 21