Okay after banging my head against a stone wall for the whole day, I figured out the solution myself.
I just modified the code a bit to serve the purpose of finding the answer to my question.
show.js
define(function (require) {
return {
result: ko.observable(),
activate: function() {
//var moviesRepository = require("repositories/moviesRepository");
var self = this;
$.ajax({
url: "controllers/displaystring.php",
type: "get",
data: {input:"show"},
dataType: "html",
success: function(data){
self.result(data);
debugger;
}});
}
};
});
displaystring.php
<?php
function display() {
echo 'Hi I am some random '.rand().' output from the server.';
}
display();
//echo "Hello World!";
?>
And that's it! You don't have to type the entire HTML code for the PHP file. Just include the PHP script and you will get the output.
Thank you all very much for your help. :)