// =================================================================================================
// As per set up in function RightMargin(), this responds to table links clicked in the right margin
function loadTables(event)
{
event.preventDefault() ;
var thislink=$(this).attr('href') ; // The URL of the link clicked
var destination='#' + $(this).data('target'); // The TARGET of the link clicked
var id_of_rowno='#' + $(this).data('link'); // Add'l info in the <input> element
var rowno = $(id_of_rowno).val() ; // Reads the value the the counter
var tablename= $(this).data('link'); // Use this value, ~ RtMgn_tablename
tablename = tablename.substring(6) ; // to extract the table whose data must be loaded
// getRandomIntInclusive(min, max) // Thinking (now) that I'll populate the form
var uniq_file_id = getRandomIntInclusive(1, 9999999999) ; // and have to save it uniquely before loading it
// This function will do the AJAX and return the page to load the the form populated
// after the SQL activity
// However when I run this, I'm getting the alert messages below as the very first thing,
// before it even call this function!!!
// ENTER PROMISES
var new_url = "" ;
if (tablename=="Modem")
{
// =================================================================
var maybe = new Promise(
// The resolver function is called with the ability to resolve or
// reject the promise
function(resolve, reject)
{
new_url = clicked_rightmarginTableLink(tablename, rowno, thislink, uniq_file_id) ;
resolve(new_url) ;
} // EO function for resolve or reject
) ; // EO Promise defined
maybe.then(
// Log and use the fulfillment value
function(new_url) {
alert("new_url="+new_url) ;
// Load the file
// $(destination).load("http://10.139.164.191/Cell_Modems/public_html/temp/modem_table_3671212420.html", function( response, status, xhr )
$(destination).load(new_url, function( response, status, xhr )
{
if ( status == "error" )
{
var msg = "Sorry but there was an error: ";
alert( msg + xhr.status + " " + xhr.statusText );
} // EO IF
}) ; // EO Callback for load AND load method itself
alert("Past .load") ;
})
.catch(
// Log the rejection reason
function(reason) {
console.log('Handle rejected promise ('+reason+') here.');
});
} // EO IF "Modem"
else
{
// Load the file (will be changed from this in the near future, once I get ajax deferred/promised/bleah!)
$(destination).load(thislink, function( response, status, xhr )
{
if ( status == "error" )
{
var msg = "Sorry but there was an error: ";
alert( msg + xhr.status + " " + xhr.statusText );
}
}) ;
} // EO else not "Modem"
} // EO function loadTables(event)
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE