Send JSON by cURL always returns “No access”

前端 未结 2 1046
遇见更好的自我
遇见更好的自我 2021-01-22 04:16

I have this JSON data:

$.ajax({
    type: \"GET\",
    url: \"http://www.example.com/test.php\",
    data:\"code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b         


        
2条回答
  •  时光说笑
    2021-01-22 04:45

    First check http://www.example.com/test.php

    Ajax system can't be used with full domain name.

    so you should use /test.php

    Then checking for an error that occurs in your site or target site.

    Then the code becomes:

    $.ajax({
        type: "GET",
        url: "/test.php",
        data:"code=Sh9QA&token=0982ff3066a3c60dbd3ecf9bcafc801b",
        contentType: "application/json; charset=utf-8",
        success: function(data, textStatus) {   
            alert(data);
            data = $.parseJSON(data);
        },
        error : function(data, textStatus, error){                  
            alert(data + "  : "+ textStatus);
        }
    });
    

提交回复
热议问题