oop - is there any more standard way to resume function from jQuery ajax call? -


i trying write big project involves of lot of code. that's why want separate functionalities different files.

the first file, datajs, make ajax call data json file. second file, showjs want display data obtained datajs file.

when comes implementation, realise ajax call takes longer time , though include datajs , showjs in order, showjs still null data

therefore made function called continuefromdatajs() in showjs file , call continuefromdatajs() @ end of ajax success function.

i think it's rather makedo solution. there standard way it?

in addition, intellisense in visual studio gone. despite separate files, there way make visual studio intellisense datajs?

thank you

sorry, don't know how add follow question code

for simplicity rename of files , take part out of it. hope helps

code in html

code in datajs.js

var planets = []; var jsondata = null;  $(function () {  $.getjson("scripts/planetdata.js", function (data) {     //planets[0] = new planet("uranus", "career", 45, 700, 400, 0.1, 5, 3);     jsondata = data;     (var = 0; < data.planets.length; i++) {          var curplanet = data.planets[i];          planets[i] = new planet(curplanet.graphic, i, curplanet.field, curplanet.planetinitialangle, curplanet.distancefromstar, curplanet.planetradius, curplanet.planetrevolvingspeed, curplanet.planetrotationspeed, curplanet.contents.length);          $("#result").append("<p>" + curplanet.graphic + " " + curplanet.field + " " + curplanet.planetinitialangle + " " + curplanet.distancefromstar + " " + curplanet.planetradius + " " + curplanet.planetrevolvingspeed + " " + curplanet.planetrotationspeed + " " + curplanet.contents.length + "</p>");      }       calldisplayscript(); //**continue showjs.js file way this?**      });  }); // more functions below in datajs.js 

showjs.js

function calldisplayscript() { **// ugly part. what's proper way it?**     $("#display #close").click(function () {         $("#display").fadeout('slow');     });     $article = $("#display article");     $article.empty();     var data = jsondata.planets[pid].contents; // **this line won't jsondata if it's out curly brace.**      (var = 0; < data.length; i++) {         $article.append(data[i].title);         $article.append(data[i].content);     }      $("#display").fadein('slow'); }; 

don't forget answer intellisense question. want in datajs.js automatically hint planets , jsondata declared in datajs.js possible?


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -