I'm working on Android GCM console that shown all register users and I can send Individual or mass message. My individual message works but cannot handle Ajax to send a mass message. This is my UI code:
$(document).ready(function(){
$(".send_all").click( function()
{
var msg = $(this).parent().find('.txt_message').val();
$.ajax({
url: "send_mass_message.php",
type: 'GET',
data: {"message": msg},
beforeSend: function() {
},
success: function(data, textStatus, xhr) {
$('.txt_message').val("");
}
});
});
});
UPDATED:
I tested the send_mass_message.php with passing parameters with URL and it works. so my problem is with Ajax part.
send_mass_message.php:
<?php
if (isset($_GET["message"])) {
$message = $_GET["message"];
include_once 'config.php';
include_once 'db_functions.php';
$db = new DB_Functions();
$users = $db->getPURCHASEDUsers();
$count = mysql_num_rows($users);
$message = array("message" => $message);
//echo $message;
include_once 'GCM.php';
$gcm = new GCM();
while($row = mysql_fetch_array($users)){
$regId = $row["gcm_regid"];
$registatoin_ids = array($regId);
$result = $gcm->send_notification($registatoin_ids, $message);
echo $result;
}
}
?>