Originally, this CP is a single-send SMS interface. Due to various reasons, it needs to be sent in bulk. Each time a message is edited, all members of the website (tens of thousands of membership records) are sent to all members of the website. The difficulty of the program lies in the tens of thousands of different database servers from MYSQL to MSSQL. Row records are inserted and updated, and the progress of sending is displayed in real time, and the results after sending are fed back.
There are the following requirements during the text message sending process:
1) Program timeout is not allowed; 2) Automatically detect the validity of the mobile phone number; 3) Calculate the progress ratio of sending;
4) Thousands of rows of records can be inserted and updated between different database servers from MYSQL to MSSQL without overloading SQL statements;
Briefly describe the solution:
Use an AJAX script in JQ to submit an application for sending SMS records. The program reads the application record, uses SESSION to record the progress data, and returns the mobile phone number of the unsent SMS in the record according to the number of messages sent each time. Before sending the program Add mobile phone legality verification. AJAX receives the first returned record data, submits the mobile phone number to a recursive function, and then repeatedly submits the remaining mobile phone numbers in the function until the progress reaches 100%.
I don’t know and I didn’t explain it clearly. The reference code is as follows:
function send_onesms(s,p,sendid){ //This is the first AJAX send
if (sendid==){
$.prompt(You haven’t selected a text message to send yet?,{buttons:{OK:true}});
return false;
}
var totel = ;
$(#loading).show();
$.ajax({
Timeout: 36000,
Type: "GET",
URL: "/admincp/page.php",
Data: "showtype=2&page="+p+&sendid=+sendid,
beforeSend: function(){
$.ajax({async:true,url: "/admincp/jindu.php?act=clear&rnd="+new Date().getTime(), success: function(response){$("#jindu").html (response);}, dataType: "html"});
$(a.sendclass).html(locked state).removeAttr("onclick");
$(#sid+sendid).html(Sending...).removeAttr("onclick");
},
Success: function(msg){
$(#i2page).val=p;
//$(#smslist).html(unescape(msg));
//$(#loading).hide();
If (msg!=over){
totel = msg;
// setInterval(function() { $.ajax({async:true,url: "/admincp/jindu.php?rnd="+new Date().getTime(), success: function(response){$(" #jindu").html(response);}, dataType: "html"}) },1000);
}
}
});
Send_sms(s,p,sendid,totel);
//window.clearInterval(thread);
}
function send_sms(s,p,sendid,totel){ //A recursive function
$.ajax({
Timeout: 36000,
DataType: "html",
Type: "POST",
URL: "/admincp/page.php?rnd="+new Date().getTime(),
data: "showtype=2&page="+p+&sendid=+sendid+&totel=+totel,
Success: function(response){
If (response!=over){
$.ajax({async:true,url: "/admincp/jindu.php?rnd="+new Date().getTime(), success: function(response){$("#jindu").html(response );}, dataType: "html"});
setTimeout(send_sms(s,p,sendid,response),1000);
}else{
$.ajax({async:true,url: "/admincp/jindu.php?act=over&rnd="+new Date().getTime(), success: function(response){alert(response);}, dataType: "html"});
$(#loading).hide();
menu_sec2_move(p);
}
}
});
}