Advertisement
Guest User

why doesn't it push the result to data?

a guest
Apr 25th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define(["dojo/_base/declare","dojo/request/xhr","dojo/dom","dojo/dom-construct","dojo/on"],
  2. function(declare, xhr,dom,domConst,on){
  3. return declare(null,{
  4.     data : [],
  5.    
  6.     constructor : function( ){
  7.             this.getdata();
  8.         },
  9.    
  10.         //gets Data
  11.     getdata : function(){
  12.         xhr("sqlaccess.php?order=0").then(function(text){
  13.                                                                                         this.prepare_str(text.toString().split(";"));});
  14.             return this.data;
  15.         },
  16.         //push Data to Array   
  17.     prepare_str : function(str){
  18.         alert(str);
  19.         for(var index = 0; index < str.length; index++)
  20.         {
  21.             data.push({name:str[index], id: index});
  22.         }
  23.         //get
  24.         },
  25.        
  26.    
  27.     //constructor
  28.    
  29.        
  30.    
  31.        
  32.         //Insert New Entry
  33.     setdata : function(str)
  34.     {
  35.         xhr("http://localhost/sql/sqlaccess.php?order=1&val="+str).then(function(text){
  36.                                                                                                             alert("Result = " + text);
  37.                                                                                                         });
  38.     },
  39.    
  40.     //update Entry
  41.     updatedata : function(str,former){
  42.         xhr("http://localhost/sql/sqlaccess.php?order=2&val="+str+"&former="+former).then(function(text){
  43.                                                                                                                                 alert("Result = " + text);
  44.                                                                                                                             });
  45.         },
  46.        
  47.         //Delete Entry
  48.     deletedata : function(str) {
  49.         xhr("http://localhost/sql/sqlaccess.php?order=3&val="+str).then(function(text){
  50.                                                                                                             alert("Result = "+text);
  51.                                                                                                         });
  52.         },
  53. });
  54. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement