简体   繁体   中英

Cross domain ajax request does not send response

I am trying to validate the PAN card detail. http://searchpan.in/search-pan-details-pan-no by using the ajax call i am trying to validate the pan card entered by user. I am sending pan number to this url using ajax call http://searchpan.in/pan-verify-26072017.php

function callbackFnc(data) {
                console.log(data)
            }
            function check() {
                $.ajax({
                    crossOrigin: true,

                    type: "Post",
                    data: {
                        pan_numbers: $("#pannumber").val()
                    },
                    url: "http://searchpan.in/pan-verify-26072017.php",
                    dataType: 'JSONP',
                    headers: {
                        'Accept': "application/json, text/javascript, */*; q=0.01",
                        'Content-Type': "application/x-www-form-urlencoded; charset=UTF-8",
                        'X-Requested-With': "XMLHttpRequest"
                    },
                    jsonpCallback: 'callbackFnc',
                    success: function (data) {
                        alert(data);
                    }
                });


<form id=""  method="post"action="verify.php">
            Pan Number<input name="number" id="pannumber">
            <input type="button" onclick="check()"value='verify'>
        </form>

I have checked and all the relevant question and applied the given solution but not getting the response. Is this a correct way to do ? or please let me know how could we do,to get the response from http://searchpan.in/pan-verify-26072017.php

pan-verify-26072017.php的 <?php之后设置以下行,这应该可以工作

    header('Access-Control-Allow-Origin: *');

try this simple ajax

var pan_number = $("#pannumber").val();

$.ajax({
         type: 'POST',
         url: "http://searchpan.in/pan-verify-26072017.php",
         data: {'pannumber': pan_number},
         success: function (data) {
               alert(data);
                    }
                });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM