$ch = curl_init(); // Initializing
curl_setopt($ch, CURLOPT_URL,"http://api.smsgatewayhub.com/smsapi/pushsms.aspx?user=stthomasmtc&pwd=429944&to=9176411081&sid=STMTSC&msg=Dear Sam,%20choir%20practice%20will%20be%20held%20in%20our%20Church%20on%20July%2031%20at%208:00%20pm.%20Thanks,%20St.%20Thomas%20MTC!&fl=0&gwid=2"); // Set URI
curl_setopt($ch, CURLOPT_HEADER, 0); //Set Header
curl_setopt($ch, CURLOPT_TIMEOUT, 300); // Time-out in seconds
$result = curl_exec($ch); // Executing
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($httpCode != 200) {
$result = ""; // Executing
}
curl_close($ch); // Closing the channel
return $result;
< /code>
Но это не сработало, как и ожидалось ... Я попытался использовать код JavaScript в PHP Echoed, но так как этот файл PHP был вызван через Ajax, этот скрипт не выполнял ..: (< /p>
вызов pgm < /p>
< /p>
< /p>
< /p>
< /code>
и функции Javascript < /p>
function send_sms()
{
var sms_msg=(document.getElementById('preview_box').value).trim();
/* var prayer_group_nm=(document.getElementById('prayer_group').value).trim();
if ((recepient==='prayer_grp')&&(prayer_group_nm==='select'))
{
alert('Select the appropriate Prayer group');
return;
}
*/
if (sms_msg==='')
{
alert ('Preview MSG prior to sending!');
}
else
{
myurl = '../sp/send_sms_sp.php';
parms="?recepient="+recepient+"&sms_msg="+sms_msg;
modurl = myurl+parms;
if (recepient==='prayer_grp')
{
modurl=modurl+"&prayer_group_nm="+prayer_group_nm;
}
response='sms_templates_response'; //setting div where response is being displayed
swtch='send_sms_state';
ajax_call.call();
//removing earlier checked state of radio buttons
$("input:radio").attr("checked", false);
document.getElementById('preview_box').value='';
//hiding out unwanted divs
$(".button_div").hide();
$("#preview").hide();
}
}
< /code>
и функция ajax_call () ... < /p>
function ajax_call()
{
var xmlhttp;
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState===4 && xmlhttp.status===200)
{
if (swtch!=='preview')
{
document.getElementById(response).innerHTML=(xmlhttp.responseText);
}
else
{
raw_template=xmlhttp.responseText;
//do not move the below code to the calling function - as it has a bug.. will not work as expected, if done
modified_msg='';
get_modified_msg.call();
document.getElementById(response).value='Dear (name), '+modified_msg.trim()+'. Thanks, St. Thomas MTC!';
}
// return;
}
else
{
if (swtch!=='preview')
{
document.getElementById(response).innerHTML ='
[img]../animation/ajax-loader.gif[/img]
';
}
}
}
xmlhttp.open("GET", modurl, true);
xmlhttp.send();
} // return;
};
< /code>
и вызываемый php < /p>
Подробнее здесь: [url]https://stackoverflow.com/questions/25091659/how-to-execute-a-link-in-ajax-called-php-script[/url]
Но это не сработало, как и ожидалось ... Я попытался использовать код JavaScript в PHP Echoed, но так как этот файл PHP был вызван через Ajax, этот скрипт не выполнял ..: (< /p>
вызов pgm < /p>
< /p>
< /p>
< /p>
< /code>
и функции Javascript < /p>
function send_sms() { var sms_msg=(document.getElementById('preview_box').value).trim(); /* var prayer_group_nm=(document.getElementById('prayer_group').value).trim(); if ((recepient==='prayer_grp')&&(prayer_group_nm==='select')) { alert('Select the appropriate Prayer group'); return; } */
if (sms_msg==='') { alert ('Preview MSG prior to sending!'); } else {
response='sms_templates_response'; //setting div where response is being displayed swtch='send_sms_state';
ajax_call.call();
//removing earlier checked state of radio buttons $("input:radio").attr("checked", false); document.getElementById('preview_box').value='';
//hiding out unwanted divs $(".button_div").hide(); $("#preview").hide();
}
} < /code>
и функция ajax_call () ... < /p>
function ajax_call() { var xmlhttp; { if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState===4 && xmlhttp.status===200) { if (swtch!=='preview') { document.getElementById(response).innerHTML=(xmlhttp.responseText); } else { raw_template=xmlhttp.responseText; //do not move the below code to the calling function - as it has a bug.. will not work as expected, if done modified_msg=''; get_modified_msg.call(); document.getElementById(response).value='Dear (name), '+modified_msg.trim()+'. Thanks, St. Thomas MTC!'; } // return; } else { if (swtch!=='preview') { document.getElementById(response).innerHTML =' [img]../animation/ajax-loader.gif[/img] '; }