0

the json data the url return

{"s":"1","m":{"u":{"id":1043,"sn":5,"e":null,"p":"Lusers/2014/08/04/09/1407117513448.jpg","nn":"LandRoverq","ci":null,"m":"18661035698","im":"1","bd":"1982-05-20"},"a":"1.7"} }

the js hanlde it

$("body").undelegate(".mem_gc_btn","click").delegate(".mem_gc_btn","click",function(){
    $(".pyloading").show();

   $.ajax({
        url :  "http://api.p1pai.com:8388/d/v3.0/u/d?jc=?&u=1043&tk=8E1266E084592E3732AEAE8426A2EE38&mc=8942A0A8-781A-43A8-A472-BD802BD56816&k1=v2LgZ2flnOSixUJH93ERsgrA2f7idFinmQpg8X4ZvYsY7zvG07kJR/G35Sioflce",
        dataType : "json",
        type : "post",
        contentType: "application/json",
        success: function(json) {
                 $(".pyloading").hide();
                 if (json) {
                    alert('success');
                  }else{
                    alert('failed');
                  }
            }
        });

but i use firebug in firefox,it show this error! enter image description here

Methew
  • 405
  • 1
  • 7
  • 11
  • 1
    Did you paste the JSON in your console? In that case, you have to enclose it in parentheses `()`, otherwise the parser will think the first curly brace is the start of a block instead of an object literal. – Frédéric Hamidi Aug 13 '14 at 09:19
  • 1
    looks like a php error, I don't know why? – Mritunjay Aug 13 '14 at 09:20
  • maybe you didn't close the parenthesis of function from "delegate" – Marin Vartan Aug 13 '14 at 09:22
  • @Mritunjay, because the number of ways one can express *I expected a semicolon here* is finite, and therefore there can be some overlap in the error messages emitted by different parsers. – Frédéric Hamidi Aug 13 '14 at 09:23
  • suppose, here `CROSS DOMAIN` issue, `OP` is trying to access API url by ajax.. – Girish Aug 13 '14 at 09:25
  • try to remove breaklines ( $json = str_replace("\n","", $json) if you use php ) on server side – Marin Vartan Aug 13 '14 at 09:28
  • @Marin Vartan,sorry,i just use freemark,rather than php.but may be they have the same solution – Methew Aug 13 '14 at 09:33
  • @Girish,i can not get your mind ,you can say more detailed,right? – Methew Aug 13 '14 at 09:35
  • Judging by the error message the JSON is executed as code. That suggests that the URL is in a different domain (as Girish suggested) so that the `ajax` method does a JSONP request instead of JSON. – Guffa Aug 13 '14 at 09:36
  • for more detail http://stackoverflow.com/questions/3506208/jquery-ajax-cross-domain – Girish Aug 13 '14 at 09:39
  • @Frédéric Hamidi,no,i put the url on the firefox address bar,and this Json is what it back for me,but i had use some Json tool to check it whether valid or not,and it is a valid data.but what is the matter? – Methew Aug 13 '14 at 09:39

0 Answers0