Click here to Skip to main content
15,890,399 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to get data from this domain ![^]


( I will will edit source of the code of the above mentioned domain from chrome and paste the code , then through jquery timer I will fire post request to send data to specific interval to a separate domain .



Other words send data from ABC Home Page - ABC.com[^] to http://www.mydomain.com/ReqData.asmx[^] using JQUERY .




and want to post the data to http://www.mydomain.com/ReqData.asmx/SDT[^]

I have implemented
jsonp
but getting error while posting data.



Error :

GET http://www.mydomain.com/ReqData.asmx/SDT?callback=jQuery21300395526289036674_1546584101987&{%22KeyV1%22:%224%22,%22KeyV2%22:%222019%22,%22ScriptName%22:%22ITC%22,%22OpenVal%22:%22100%22,%22CloseVal%22:%22100.2%22,%22HighVal%22:%22101%22,%22LowVal%22:%2299.5%22}&_=1546584101988 net::ERR_ABORTED 500 (Internal Server Error)




IIS Eror Log -

2019-01-04 06:41:40 172.31.80.6 GET /WebRequest.asmx/SDT callback=jQuery21300395526289036674_1546584101987&{%22KeyV1%22:%224%22,%22KeyV2%22:%222019%22,%22ScriptName%22:%22ITC%22,%22OpenVal%22:%22100%22,%22CloseVal%22:%22100.2%22,%22HighVal%22:%22101%22,%22LowVal%22:%2299.5%22}&_=1546584101988 80 - 157.40.70.220 Mozilla/5.0+(Windows+NT+6.1;+Win64;+x64)+AppleWebKit/537.36+(KHTML,+like+Gecko)+Chrome/71.0.3578.98+Safari/537.36 - 500 0 0 531




Please help .

What I have tried:

$.ajax({
            type: "POST",
            contentType: 'application/json; charset=utf-8',
            dataType: 'jsonp',
            crossDomain: true,
            url: 'http://www.mydoman.in/ReqData.asmx/SDT',
            headers: {
                "Access-Control-Allow-Credentials": "true",
                "Access-Control-Allow-Origin": "*",    
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            },            
            data: JSON.stringify({
                KeyV1: "4",
                KeyV2: "2019",
                ScriptName: "ITC",
                OpenVal: "100",
                CloseVal: "100.2",
                HighVal: "101",
                LowVal: "99.5"
            }),
            success: function (result) {
                alert(JSON.stringify(result));
            },
            error: function (xhr, status, error) {
                alert(status);
            }
        });
Posted
Updated 3-Jan-19 20:18pm
v4
Comments
j snooze 4-Jan-19 17:37pm    
a 500 error usually means the server side code is failing, not the client side javascript.
biswa85 5-Jan-19 14:16pm    
Thank you. I have solve the existing problem .


But I have one more quest . After pasting the code on http://www.test.com website from browser I am not able to trigger my method . Please help me to solve the issue .

Meaning -

I have opened website in browser .
Inspect the element and paste the bellow mentioned jquery in website.
Then my method should suppose to trigger automatically as jquery time implemented .

Please guide me .


@script block start

function SVDT(KeyV1, KeyV2, ScriptName, OpenVal, CloseVal, HighVal, LowVal) {


$.ajax({
type: "GET",
contentType: 'application/json; charset=utf-8',
dataType: 'jsonp',
crossDomain: true,
url: 'http://www.xxxx.com/MyRequest.asmx/ABC',
headers: {
"Access-Control-Allow-Credentials": "true",
"Access-Control-Allow-Origin": "*",
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
},
data: {
KeyV1: KeyV1,
KeyV2: KeyV2,
ScriptName: ScriptName,
OpenVal: OpenVal,
CloseVal: CloseVal,
HighVal: HighVal,
LowVal: LowVal
},
success: function (result) {
//alert(JSON.stringify(result));
},
error: function (xhr, status, error) {
//alert(error);
}
});


}

var x = setInterval(function () {
$(".info").each(function () {
var scriptname = $(this).find(".symbol .nice-name").html();
var scriptprice = $(this).find(".price .last-price").html();
SVDT(keyDate, keyYear, scriptname, scriptprice, -1, -1, -1);
});
}, 10000);

@script block end

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900