Cordova And Express Js?
I am really lost when it comes to rendering express views onto the client, when the client is a cordova app. There are a few obvious things, for example the app would need to make
Solution 1:
Use AJAX to make calls from your application to your server. This can be done in pure JavaScript or easily with libraries like jQuery or frameworks like AngularJS.
Ex in pure JS:
var xmlhttp=new XMLHttpRequest();
xmlhttp.open("GET","my/route",true);
xmlhttp.send();
and fetch response with
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("aDiv").innerHTML=xmlhttp.responseText;
}
}
Or with jQuery :
$.get( "my/route", function( data ) { $( ".aDiv" ).html( data ); });
However, usually, on Cordova apps, views are stored on the client side, and only data are being fetched through AJAX requests to speed up the app.
Post a Comment for "Cordova And Express Js?"