labithiotis's Recent Forum Activity

  • I've tweaked it further because of an issue with additional appends.

    <img src="https://dl.dropboxusercontent.com/u/2175584/Construct2Examples/Append.JPG" border="0" />

  • I want the keys to extend, in that example only D was added becuase it was new.

    I have done it by hacking the json data like so:

    Ajax on "Complete" | DataLoaded | Load hash from JSON string Ajax.LastData
    
    var text appendData = ""
    
    System : dataLoaded.itemcnt("") > 0 
    
      System for "" from 0 to DataLoaded.ItemCnt("")-1 | Add DataLoaded.at (str(loopindex) to appendData
    
           System append =! "" && loopindex < dataLoaded.itemCnt("")-1 | Add "," to appendOrders
    
      System DataAll.itemCnt("") = 0 | System : set appendData to "[" & appendData & "]"
    
                                     | dataAll Load hash table from JSON string appendData
    
    

    I want to do this :

    Table A (Loaded) : [ 1:"A", 2:"B" ]

    Table B (All) : [ 1:"X", 2:"Y" ]

    Result after merging/appending A with B : [ 1:"A", 2:"B", 3:"X", 4:"Y"]

    with the current merge that result is : [ 1:"X", 2:"Y" ] has it has merge the indexes.

    Note- the root is blank from my server and I can't change that:

    [
     {
       "ID": 129,   
       "X": X
     },
     {
       "ID": 130,   
       "X": X
     },
     {
       "ID": 131,   
       "X": X
     }
    ]
  • How can I append a hash table. I have two tables one that has the loaded ajax call and another that's the stored table. As I want to check the server every few mins for updates and push them into the stored table.

    I have tried to use the merge but that's not giving me the correct results as it overwrites current keys rather than appending them.

    Also tried to use set value and ussing itemkeycount to get last root key and set value from loaded hash table but I get \ in the json.

  • easeTween without doubt is the most used plugin i use.

  • Hey all,

    Is there a chat channel, even after searching forums i can't find any details for a channel.

  • I have tried to make a plugin with Jquery but not making much progress. I have the following if anyone can help that would be awesome.

    https://dl.dropboxusercontent.com/u/85804468/jajax.zip

         

    instanceProto.doRequest = function (tag_, url_, method_, data_, headerkey_, headervalue_)
         {
    // Create a context object with the tag name and a reference back to this
              var self = this;
              var requestAjax;
              
              var errorFunc = function () {
                        self.curTag = tag_;
                        self.runtime.trigger(cr.plugins_.JAJAX.prototype.cnds.OnError, self);
                   };
              
              try {
                   if ( method_ === "POST" && data_ ) {
                    requestAjax = $.AJAX({
                                  beforeSend: function(xhr){
                                            xhr.setRequestHeader('auth', 'hash');
                                            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                                            xhr.setRequestHeader("Content-Length", data_.length);
                                       },
                                  type: method_,
                                  url: url_,
                                  data: data_ ,
                            contentType: 'application/x-www-form-urlencoded',
    
                            success: function (data) {
                                            self.HeaderResponce = xhr.getResponseHeader( headerkey_ );
                                    self.lastData = data.replace(/\r\n/g, "\n");
                                            self.runtime.trigger(cr.plugins_.JAJAX.prototype.cnds.OnComplete, self);
                                       },
                                  error: function() {
                                            errorFunc();
                                       }
                                       
                             });     
                        }
                   if ( method_ === "GET" ) {
                    requestAjax = $.AJAX({
                                  beforeSend: function(xhr){
                                            xhr.setRequestHeader('auth', 'hash');
                                            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                                            xhr.setRequestHeader("Content-Length", data_.length);
                                            xhr.setRequestHeader(headerkey_, headervalue_);
                                       },
                                  type: method_,
                                  url: url_,
                                  success: function (data) {
                                            self.HeaderResponce = xhr.getResponseHeader( headerkey_ );
                                            self.lastData = data.replace(/\r\n/g, "\n");
                                            self.runtime.trigger(cr.plugins_.JAJAX.prototype.cnds.OnComplete, self);
                                       },
                                  error: function() {
                                            errorFunc();
                                       }
                                       
                             });     
                        }
                   if ( method_ === "PUT" ) {
                    requestAjax = $.AJAX({
                                  beforeSend: function(xhr){
                                            xhr.setRequestHeader('auth', 'hash');
                                            xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                                            xhr.setRequestHeader("Content-Length", data_.length);
                                            xhr.setRequestHeader(headerkey_, headervalue_);
                                       },
                                  type: method_,
                                  url: url_,
                                  success: function (data) {
                                            self.HeaderResponce = xhr.getResponseHeader( headerkey_ );
                                            self.lastData = data.replace(/\r\n/g, "\n");
                                            self.runtime.trigger(cr.plugins_.JAJAX.prototype.cnds.OnComplete, self);
                                       },
                                  error: function() {
                                            errorFunc();
                                       }
                                       
                             });     
                        }
                   }
    
    
  • I tried that but wasn't sure if it was being used in normal browsers, also my normal ajax stops working. I will upload what i have done thus far

  • Hi, if anyone can help me to make a ajax plug (working off default plugin) to do PUT and GET request with custom headers and header responses

    http://www.scirra.com/forum/topic66799_post410385.html#410385

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hi,

    I need an ajax plugin to handle using PUT method and to submit a GET request with a custom header and get the response header too.

    I have copied the oringal ajax plugin and got the PUT action, but i am trying to add a GET request with custom headers & response. I am struggling to get that to work.

    [b]Edittime.js[/b]
    AddStringParam("Tag", "A tag, which can be anything you like, to distinguish between different AJAX requests.", "\"\"");
    AddStringParam("URL", "The URL to put to.  Note: most browsers prevent cross-domain posts.", "\"http://\"");
    AddStringParam("Data", "The data to put, in query string form.  Be sure to URLEncode any user-entered data.");
    AddAction(3, 0, "Put to URL", "AJAX", "PUT <b>{2}</b> to URL <b>{1}</b> (tag <i>{0}</i>)", "Make a PUT request to a URL.", "Put");
    
    AddStringParam("Tag", "A tag, which can be anything you like, to distinguish between different AJAX requests.", "\"\"");
    AddStringParam("URL", "The URL to put to.  Note: most browsers prevent cross-domain posts.", "\"http://\"");
    AddStringParam("HeaderKey", "Header Key");
    AddStringParam("HeaderValue", "Header Value");
    AddAction(4, 0, "Request URL with Header", "AJAX", "Request <b>{2}</b> to URL <b>{1}</b> (tag <i>{0}</i>) with header: <i>{3}</i> with <i>{4}</i>", "Request URL with Header.", "RequestHeader");
    
    AddExpression(2, ef_return_string, "Get Header Responce", "AJAX", "HeaderResponce", "Get the header responce");
    
    [b]Runtime.js[/b]
    Acts.prototype.Put = function (tag_, url_, data_)
     {
         this.doRequest(tag_, url_, "PUT", data_);
     };
    
    Acts.prototype.RequestHeader = function (tag_, url_, headerkey_, headervalue_)
     {
         this.doRequest(tag_, url_, "GET", headerkey_, headervalue_);
     };
    
    Exps.prototype.HeaderResponce = function (ret)
     {
         var requests;
              
         this.xhr = sinon.useFakeXMLHttpRequest();
         this.xhr.onCreate = function(xhr) {
           ?requests.push(xhr);
         }
              
         ret.set_string(requests);
     };
    
    

    But when i added either of these the normal ajax call action stops working.

    Any help would be great.

    Need to have something working by end of day :(

  • Oh, Data.Hours & Minutes can actually take an argument for time, it doesn't show that when I use the expression so I just assumed it used current time only.

    Thanks

  • Format unix timestamp to a formatted time like HH:MM

    Those function produces a unix time stamp, not what I was asking for. (i.e. 1363058603023)

    I want some expressions to take that number (AN UNIXTIMESTAMP / 1363058603023 ) and convert it to HH:MM or indervidually to Hours, Mins, and seconds so I can display that stamp as a time in UI.

    1363058603023 --> 14:23 / 2:23pm

  • Can you add the ability to format unix timestamp to a formatted time like HH:MM, tried adding it myself but it didn't work.

    // create a new javascript Date object based on the timestamp
    // multiplied by 1000 so that the argument is in milliseconds, not seconds
    var date = new Date(unix_timestamp*1000);
    // hours part from the timestamp
    var hours = date.getHours();
    // minutes part from the timestamp
    var minutes = date.getMinutes();
    // seconds part from the timestamp
    var seconds = date.getSeconds();
    
    // will display time in 10:30:23 format
    var formattedTime = hours + ':' + minutes + ':' + seconds;
    
labithiotis's avatar

labithiotis

Member since 4 Feb, 2013

None one is following labithiotis yet!

Connect with labithiotis

Trophy Case

  • 11-Year Club
  • Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

13/44
How to earn trophies