Is there a way to call a JavaScript file in an Ajax call and use logic in that file?
For instance, I am currently calling a JSON file using Sencha Touch like this:
Ext.Ajax.request({
url : 'resources/data/userdata.json',
headers : {
"Content-Type" : "application/json"
},
callback : function (options, success, response) {
obj = JSON.parse(response.responseText);
for (var i = 0; i < obj.length; i++) {
console.log(obj[i].name);
}
}
});
But is it possible to call a JavaScript file and do some logic in that file maybe based on the parameters sent in?
I know I can do this with server files (ASP.NET, PHP, etc.)... I was just wondering if this is possible using a JavaScript file.
I tried calling a window.onload function or using an immediate function, but I still get ALL the text back in the file instead of just the JSON that I am trying to return...:
(function(){
return '[{ "name": "todd", "lastname":"vance"}, { "name": "joe", "lastname":"schmoe"}] ';
})();