totallybueno

Send data to .php with Cocoonjs Canvas+

Recommended Posts

Hi there,

I made my game and even my leadersboard system and everything works fine, I´m having a beautiful 60fps in my game and I get/save scores perfectly, on desktop and cocoon´s Webview+

 

The problem is that I tried my game in an old smartphone and it´s running a little bit slower, so I changed to Canvas+ and now I´m getting those 60fps even in old smartphones.

 

The problem is that I´m not being able to save the scores if I use Canvas+. At the beginning I was using jQuery (just for that... I know...) this way:

$.getJSON( path+"getScores.php", { game: "1", order: "ASC" }).done(function(data) {     this.checkScore(data.scores[9])})

And everything was working fine until cocoon started to throw weird errors about jQuery, so I changed to XMLHttpRequest this way:

var http = new XMLHttpRequest();var url = path+"getScores.php";var params = "game=1&order=ASC";http.open("POST", url, true);http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");http.setRequestHeader("Content-length", params.length);http.setRequestHeader("Connection", "close");http.onreadystatechange = function() {//Call a function when the state changes.     if(http.readyState == 4 && http.status == 200) {          alert(http.responseText);     }}http.send(params);

Now I have the same problem, working on desktop, working on webview+ and no working on canvas+ (but no errors, simply not working).

 

So my question is, how would you send some data to a .php file using canvas+? It seems (to me) that is not possible at all...

Share this post


Link to post
Share on other sites

Hello,

 

I have been using XHR request with Canvas+ and did not have any problems. I highly recommend you to create a custom launcher compilation. Actually, with the latest version (2.1.1) JQuery requests should also work (with a custom launcher, not the stock launcher).

 

Please, also try to pass the parameters in a GET request just in case (just to test it).

 

Hope this works.

Share this post


Link to post
Share on other sites

Hello,

 

I have been using XHR request with Canvas+ and did not have any problems. I highly recommend you to create a custom launcher compilation. Actually, with the latest version (2.1.1) JQuery requests should also work (with a custom launcher, not the stock launcher).

 

Please, also try to pass the parameters in a GET request just in case (just to test it).

 

Hope this works.

 

Where do you create a custom launcher judax? I didn´t know about that, thanks for the tip :)

 

 

 

EDIT: No worries, I found it... I´m gonna test it now.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.