I have code a request, similar to others in the code, but it pends and I don't understand why.
Here is the code in the controller :
$scope.addScroll = function(){
InternDataProvider.addScroll(globalCtrl.unscrolled)
.then(function(reports) {
console.log("Changes saved");
globalCtrl.scrollmessage="Combinaison "+globalCtrl.unscrolled.media+"/"+globalCtrl.unscrolled.platoform+" ajoutée.";
globalCtrl.scrollmessageerr="";
}).catch(function(err) {
console.error('Unable to fetch forecast report: ' + err);
});
};
The code in the factory part :
internDataProvider.addScroll = function(uscr)
{
var httpParams = {
unscrolled: uscr
};
return $http.post(addScroll, {
params : httpParams,
}).then(function(response){
console.log("Successful: response from submitting data to server was: " + response);
}).catch(function(err){
console.log(err.statusCode);
});
};
And the code in the node.js part :
//Add a combination of media or platform to the scroll
function addScroll(res, queryParams)
{
var int1 = listMedias.indexOf(queryParams.unscrolled.media) +1;
var int2 = listPlatforms.indexOf(queryParams.unscrolled.platform);
connection.query("UPDATE safeplusdb.scroll SET isscrolled="+true+" WHERE idm="+int1+" AND vector_id="+int2+";", function(err, records) {
if(err) throw err;
console.log("UPDATE safeplusdb.scroll SET isscrolled="+true+" WHERE idm="+int1+" AND vector_id="+int2+";");
connection.query("SELECT * FROM safeplusdb.scroll;", function (err, records){
if(err) throw err;
for(i=0; i<records.length; i++)
{
var record= records[i];
indj=indk=0;
if(record.isscrolled==false)
{
if(record.idm==null && record.vector_id !=null)
{
listUnScroll[indj] = {media : null, platform : null};
listUnScroll[indj].media = null;
listUnScroll[indj].platform = listPlatforms[record.vector_id];
indj++;
}
else if(record.vector_id==null && record.idm!=null)
{
listUnScroll[indj] = {media : null, platform : null};
listUnScroll[indj].platform = null;
listUnScroll[indj].media = listMedias[record.idm-1];
indj++;
}
else
{
listUnScroll[indj] = {media : null, platform : null};
listUnScroll[indj].media = listMedias[record.idm-1];
listUnScroll[indj].platform = listPlatforms[record.vector_id];
indj++;
}
}
else if(record.isscrolled==true)
{
if(record.idm==null && record.vector_id !=null)
{
listScroll[indk] = {media : null, platform : null};
listScroll[indk].media = null;
listScroll[indk].platform = listPlatforms[record.vector_id];
indk++;
}
else if(record.vector_id==null && record.idm!=null)
{
listScroll[indk] = {media : null, platform : null};
listScroll[indk].platform = null;
listScroll[indk].media = listMedias[record.idm-1];
indk++;
}
else
{
listScroll[indk] = {media : null, platform : null};
listScroll[indk].media = listMedias[record.idm-1];
listScroll[indk].platform = listPlatforms[record.vector_id];
indk++;
}
}
}
});
});
}
I obtain data in a HTML page, I use a controller (with Angular.js) to manipulate it and, I transmit it to my server.js file (node.js).
The request resulted, when I test it on Workbench, it works with no problem. But with this code, I have a request pending, like this :
When I stop the web application, the change executed by the request can be made.
So, how to explain the present pending ? How to solve this ?
via Simon Girard
No comments:
Post a Comment