hello guys i am sending sms via JSON
(first i did it by ajax but ajax does not support Cross domaon request so i had to do it with JSON
(the Ajax Code Run Only on Localhost but after deploying on server It wasnt running)
)
The Problem is that Ajax code was returning me error or sucess code by which i was showing Error sucess message
but when i implement this on JSON ,it sens sms but unable to get Status of sucess or failure
MY OLD AJAX CODE:
var req = new XMLHttpRequest();
XMLHttpRequest = createRequestObject();
function sendRequest2()
{
try
{
var createdURL = "";var page_url="123456";
createdURL="http://xx.xxx.xxx.xx/sendsms?username=USername&password=Pass&type=0&dlr=1&destination=919314371143&source=IT&message=By Ajax From Arry";
alert('NEW' +createdURL );
req.open("GET", createdURL ,true);
req.onreadystatechange = showResponse;
req.send(/*no params*/null);
}
catch(e)
{
alert('Exception'+e);
alert('Exception'+e.description);
}
finally
{
alert ('Finish');
}
}
function showResponse()
{
alert('ready state :'+req.readyState );
if (req.readyState == 4)
{ //state 4 means request is complete
if (req.responseText == "")
{ //if response text is empty then SMS Gateway Server is not running
alert('SMS Gateway Server is not running');
document.getElementById("responseText").innerHTML = " SMS Gateway Server is not running!";
}
else
{ //we write the response text on div responseText
alert(req.responseText);
document.getElementById("responseText").innerHTML = req.responseText;
}
}
else
{ //we write the response text on div responseText
alert(req.responseText);
document.getElementById("responseText").innerHTML = 'fail';
}
alert('End of Show Response');
}
///
NEW JSON CODE:
here showResponse was my function which was doing this stuff
but now i use Json
<script type="text/javascript">
function Call_Response( obj)
{
try
{
if (obj == null)
{
alert("There was a problem parsing search results.");
return 0;
}
else
{
aObj.removeScriptTag();
}
}
catch (e)
{
alert('Exception :'+e.description);
}
}
function call_me()
{
try
{
alert('CALL_ME Start');
var createdURL="http://xx.xxx.xxx.xx/sendsms?username=USername&password=Pass&type=0&dlr=1&destination=919314371143&source=IT&message=ByJSON From Arry";
var request =createdURL+ '&output=json&callback=Call_Response';
aObj = new JSONscriptRequest(request);
aObj.buildScriptTag();
aObj.addScriptTag();
alert('CALL_ME End');
}
catch (e)
{
alert('Exception :'+e.description);
}
}
</script>
here Json is not calling Call_Response which is Showing sucess or failure message
It is sending messages sucessfully but for acknowledgment ,I dont have anything,
Perhaps it is bcoz the returning data is not Json Compatible
But This Sms Sending Site Just return me a No. 1701 Which is Sucess Code and Anything else Will be a Failure
How can i do this . Plz help How To call "Call_Response" Function after the Completion of request