Unable to receive JSON from JQuery ajax call

后端 未结 3 1061
不知归路
不知归路 2021-02-20 05:01

I have determined that my JSON, coming from the server, is valid (making the ajax call manually), but I would really like to use JQuery. I have also determined that the \"post\"

相关标签:
3条回答
  • 2021-02-20 05:19

    The data parameter is wrong. Here is an example that works:

    data: { index: ddl.selectedIndex },

    This contructs an object with property called index with value ddl.selectedIndex.

    You need to remove the quotes from your data parameter line

    Good luck A

    0 讨论(0)
  • 2021-02-20 05:27

    Here are a few suggestions I would try:

    1) the 'datatype' option you have specified should be 'dataType' (case-sensitive I believe)

    2) try using the 'contentType' option as so:

    contentType: "application/json; charset=utf-8"
    

    I'm not sure how much that will help as it's used in the request to your post url, not in the response. See this article for more info: http://encosia.com/2008/06/05/3-mistakes-to-avoid-when-using-jquery-with-aspnet-ajax (It's written for asp.net, but may be applicable)

    3) Triple check the output of your post url and run the output through a JSON validator just to be absolutely sure it's valid and can be parsed into a JSON object. http://www.jsonlint.com

    Hope some of this helps!

    0 讨论(0)
  • 2021-02-20 05:46

    Why myResult instead of request?

    success: function(request) {
      alert(myResult.length);
    }
    
    0 讨论(0)
提交回复
热议问题