console.log() not showing in console but in page in Smarty - google-chrome

Ok im having this issue with some smarty files and variables and i need to use console.log.
Issue is console.log is empty and the code appears on the webpage.
for example
console.log('$affiliate.id'); console.log('$affiliate.firstname'); console.log('App started'); console.log("App started");
Shows up in tha page.
PS: Is there some kind of an issue cause its tpl files?
PS2: I tried all the versions like ', " in case i was wrong :P
Thanks in advance

You have to put your code inside <script> tags.
For example:
<script>
console.log('{$affiliate.id}'); console.log('{$affiliate.firstname}'); console.log('App started'); console.log("App started");
</script>

Related

JQuery append to IMG URL, this works, but Developer Console reports 404 errors. How to stop those errors?

The images are from a markdown template and the SRC once parsed is just the filename only, no complete URL. I append the URL with the JQuery below, and the image is loaded as expected. The issue isn't that the image file doesn't exist, it does, but the developer console reports the file not found. And because of this, the browser fails to load other dependencies, such as the RRSSB plugin, for example.
Anyone got any suggestions please? Here is the JQuery below:
$(".markdown").find("img").each(function()
{
$(this).addClass("markdown");
$(this).attr("src", function(i, value)
{
return "{{ config("website.aws.s3") }}" + value;
});
});
As I said, the actual image itself is loaded without any problems. I just need the console not to report the 404 error, that's all.

How can I include a hyperlink as a parameter in Express?

I'm trying to send a hyperlink (such as: "http://google.com") as a parameter to my Express server script. My current script looks like this:
var app = require("express")();
app.get("/new/:link(*)", function(req, res){
var link = req.params.link;
res.end(JSON.stringify({
site: link
}));
});
app.listen(process.env.PORT || 3000, function(){
console.log("Listening...");
});
This is just a test to see if I can get it working so I can build something bigger on top. The idea is that I can send a link and receive the link in JSON. However when I try to go to the site with the the link as parameter, my browser want to save a file called "google.com" and it doesn't receive any JSON from the server.
I know it's possible to do this without changing anything about my browser but I don't know how. Anyone has any ideas?
Ok, so I have accidentally fixed my problem.
Apparently i had to write "res.send(...)" instead of "end". It now works perfectly although I don't really understand why.

Angular service returning and html file instead of a json file

I've been learning MEAN stack technologies for a week now. I'm having a problem using a custom service in Angular. I try to get a .json file, but when the app loads & I examine the loaded resources in the web inspector, the ison file is showing the code from my index.html file. Does anyone know why this is happening and how to fix it?
This is the custom service:
angular.module('StudentService', [])
.factory('Students', ['$http', function($http) {
return $http.get('app/students.json');
}]);
I don't understand how it could be loaded with the title 'students.json' but show up in the web inspector as html code. Any help would be greatly appreciated.
Change your code like this
$http.get('app/students.json')
.then(function(res){
$scope.todos = res.data;
});
return $scope.todos;

Load div when i open the page

Good Morning comunity, im really new on this coding so iam sorry if this question is too noob.
I want a DIV PA load automatically a php file when i open the web page, please i dont want to load with any interval, just load instant when open web.
I tried this code but im sure it is not working
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3.0/jquery.min.js">
</script>
<script type="text/javascript">
$(document).ready(function)()
{
$('#apDiv3').load('xFile.php');
}
);
</script>
Thank you in advance for your time!!
Have you checked the result with a debugger like Firefox's Firebug? Check the network communication to see if the ajax request was completed successfully.
Also, you can try to a callback function to see if the code was executed successfully:
$( "#result" ).load( "ajax/test.html", function() {
alert( "Load was performed." );
});
if you don't get the expected output, it might be a problem on the server-side.
Also... are you sure you are using this exact code? I don't think you should close the brackets after function
$(document).ready(function)
this is how you do it:
$(document).ready(function() {
....

What is wrong with this WebWorker (no errors, but console.log are not reached)

I have the following code, trying to test out WebWorkers. I have an index.html file that looks like this:
<html>
<head></head>
<body>
<script type='text/javascript'>
var worker = new Worker('./myworker.js');
console.log('after creation');
worker.addEventListener('message', function(msg){
console.log(msg);
});
worker.postMessage();
</script>
</body>
</html>
The contents of myworker.js (which resides in the same directory as index.html) is:
this.onmessage = function(){
postMessage('got the msg, thanks');
};
When I load index.html (in Chrome 14), the 'after creation' console.log never happens. Nor anything else. Console.logs happen before the new Worker() creation, but nothing after seems to happen.
Well butter my biscuit, apparently WebWorkers do not work when loaded locally (e.g. from file://).
source: http://www.html5rocks.com/en/tutorials/workers/basics/ (bottom of content)
If you are testing app in chrome you should start the chrome with --allow-file-access-from-files or test app using Local server