codesuck codesuck - 9 months ago 38
Javascript Question

JavaScript and jQuery code to return function by var

I am working on small api to get content from my database. I want to show data in a JavaScript/jQuery function according to variables I declared.


function dataset() {
var url = "";
var name = "Mini Api";
ver version = "1.00";

this.return url;
this.return name;
this.return version;

How I intend to use it

minapi = new dataset();
//here I want to return only name

Please any idea of how to get this done?

In addition, is there a way to create jQuery function to execute once page load without using this
$( document ).ready(function() {});


I think you want this:

function dataset() {

   var myData = {
       url: "",
       name: "mini api",
       version: "1.00"

   return myData;


var myVar = dataset();