Jump to content
  • 0

Antmedia and AJAX HELP needed!!!


Ray Jender
 Share

Question


Not getting and responses to this so here it is again!

I have a this javascript that I added to the index.html:

var randomToken;


       
function get_random(){


             
var i, randomToken = "", characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";


             
var charactersLength = characters.length;


               
for (i = 0; i < 17; i++) {
                        randomToken
+= characters.substr(Math.floor((Math.random() * charactersLength) + 1), 1);
                               
}


               
var stream1 = randomToken;
                        document
.getElementById("streamName").value = stream1;
                        console
.log("stream1  = ", stream1);
               
                $
.ajax
                   
({
                                type
: "POST",
                                url
: "https://www.myserver.us:5443/WebRTCApp/poststreamID.php",
                                data
: "stream1" ,
                               
done: function()
                                       
{
                                                alert
("Success.");
                                       
},


                                fail
: function()
                               
{
                                        alert
("Sorry. Server unavailable. ");
                               
},
                   
});


               
};

And my php is:

<?php


 
//--------------------------------------------------------------------------
 
// Example php script for fetching data from mysql database
 
//--------------------------------------------------------------------------
  $servername
= "localhost";
  $username
= "root";
  $password
= "password";
  $dbname
= "WebRTCApp";
  $tableName
= "broadcast";


 
//--------------------------------------------------------------------------
 
// 1) Connect to mysql database
 
//--------------------------------------------------------------------------
 
//include 'DB.php';
 
// $conn = new mysqli($servername,$username,$password, $dbname);
 
// Create Connection
  $conn
= mysqli_connect($servername,$username,$password);


 
// Check Connection
 
if (!$conn) {
         
die("Connection failed: " . mysqli_connect_error());
 
}


  echo
"Connected Successfully";
  alert
("Success! ");


  $sql
= "UPDATE broadcast SET streamID = '9999999' WHERE id=1";
 
if (mysqli_query($conn, $dql)) {
                alert
("Record Updated!");
 
} else {
          alert
("Error: " . mysqli_error($conn);
 
}


  mysqli_close
($conn);


?>

And the Chrome dev console shows this:

XHR finished loading: POST "https://www.myserver.us:5443/WebRTCApp/poststreamID.php"

But the database is not getting updated?  And I'm not seeing any log errors?

Surely someone can advise on how to fix this?


Link to comment
Share on other sites

  • Answers 1
  • Created
  • Last Reply

Top Posters For This Question

Top Posters For This Question

1 answer to this question

Recommended Posts

  • 0
Figured it out.   I installed http://quercus.caucho.com/quercus-3.1/doc/quercus.xtp and now it is working.
I can update a mysql database from the apache-tomcat server!

Wooooo-Hooooo!

Ray

On Friday, July 19, 2019 at 6:39:39 PM UTC-4, Ray Jender wrote:

Not getting and responses to this so here it is again!

I have a this javascript that I added to the index.html:

var randomToken;


       
function get_random(){


             
var i, randomToken = "", characters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";


             
var charactersLength = characters.length;


               
for (i = 0; i < 17; i++) {
                        randomToken
+= characters.substr(Math.floor((Math.random() * charactersLength) + 1), 1);
                               
}


               
var stream1 = randomToken;
                        document
.getElementById("streamName").value = stream1;
                        console
.log("stream1  = ", stream1);
               
                $
.ajax
                   
({
                                type
: "POST",
                                url
: "https://www.myserver.us:5443/WebRTCApp/poststreamID.php",
                                data
: "stream1" ,
                               
done: function()
                                       
{
                                                alert
("Success.");
                                       
},


                                fail
: function()
                               
{
                                        alert
("Sorry. Server unavailable. ");
                               
},
                   
});


               
};

And my php is:

<?php


 
//--------------------------------------------------------------------------
 
// Example php script for fetching data from mysql database
 
//--------------------------------------------------------------------------
  $servername
= "localhost";
  $username
= "root";
  $password
= "password";
  $dbname
= "WebRTCApp";
  $tableName
= "broadcast";


 
//--------------------------------------------------------------------------
 
// 1) Connect to mysql database
 
//--------------------------------------------------------------------------
 
//include 'DB.php';
 
// $conn = new mysqli($servername,$username,$password, $dbname);
 
// Create Connection
  $conn
= mysqli_connect($servername,$username,$password);


 
// Check Connection
 
if (!$conn) {
         
die("Connection failed: " . mysqli_connect_error());
 
}


  echo
"Connected Successfully";
  alert
("Success! ");


  $sql
= "UPDATE broadcast SET streamID = '9999999' WHERE id=1";
 
if (mysqli_query($conn, $dql)) {
                alert
("Record Updated!");
 
} else {
          alert
("Error: " . mysqli_error($conn);
 
}


  mysqli_close
($conn);


?>

And the Chrome dev console shows this:


But the database is not getting updated?  And I'm not seeing any log errors?

Surely someone can advise on how to fix this?


Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share


×
×
  • Create New...