I am working in a JSONRPC webservice and I am trying to send the request to the server end to get the response. Basically I am trying to send the following details in the request
methodname//example 899
Language code
Transaction code
User ID
Password
number
Amount
Now there is the host which I need to submit the request.If I telnet the host and the port its getting connected successfully.But when I try to submit the request through the browser I am getting some net::ERR_CONNECTION_CLOSED.I am not sure why its happening.
I am not sure about the request that I am submitting but here is the request that I am submitting.And I am submitting request using the Javascript
<Script>
JSONTest = function() {
$.ajax({
url : "https://domain.com:port/",
type : 'GET',
data : {
"jsonrpc" : "2.0",
"method" : "904",
"id" : "1",
"params": [ "en", "69", "2123129930", "4371232483", "50", "" ]
},
dataType : "json",
success : function(result) {
//alert("result"+result[0]);
switch (result) {
case true:
processResponse(result);
break;
default:
resultDiv.html(result);
}
},
/* error: function (xhr, ajaxOptions, thrownError) {
alert(xhr.status);
alert(thrownError);
} */
});
};
</script>
<button type="button" onClick="JSONTest()">JSON</button>
Based on the above script I am tryiing to find the answers for the following questions.
Really appreciate your help on this.
Does your jsonrpc-server take HTTP GET-requests? If your jsonrpc-server supports http at all, the more normal approach is using POST to transfer the jsonrpc request-data.
Have you considered cross-domain restrictions from your browser?
I would guess you should make a POST-request. The data looks correct, but all this depends on the jsonrpc-server. There are ususal ways to transport jsonrpc over http, but it is not part of the protocol itself.
Make sure that the server accepts http post, and outputs the Access-Control-Allow-Origin header; see http://en.wikipedia.org/wiki/Cross-origin_resource_sharing
If you're making more than one simple post, I'd suggest a js-lib for handling the jsonrpc, like: https://github.com/Textalk/jquery.jsonrpcclient.js
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With