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);
  }
});
2
  • Console.log() does not work in IE. see stackoverflow.com/questions/14086675/… Commented Apr 22, 2015 at 4:55
  • 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. Commented Apr 22, 2015 at 6:03

2 Answers 2

1

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

Sign up to request clarification or add additional context in comments.

Comments

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);
  }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.