Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperCube > Programming and Scripting
ccbDoHTTPRequest not returning data

sassone
Registered User
Quote
2016-01-15 21:46:46

Hello ,

I am not able to have ccbDoHTTPRequest working with webgl despite trying more and more

this is the code inside CC

function finishedRequest(data)
{
var s = ccbGetSceneNodeFromName("punti");
ccbSetSceneNodeProperty(s, "Text",data);

}

ccbDoHTTPRequest("http://www.xxx.com/index2.php", finishedRequest);

this is the php code

<?php

$file = fopen("test3.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
echo('1234');

//Create a stdClass instance to hold important information
//$return = new stdClass();
//$return->success = true;
//$return->errorMessage = "";
//$return->data = array();

//Assign the altered data to a property of $return
//$return->data['test'] = 'test';


//Encode the stdClass object containing information and return data as //a json string
//$json = json_encode($return);

//Return the json string to the client
//echo $json;
?>

I am sure the PHP file is reached because the test3.txt file has been written but data returned is always empty ( also tried using json data , changing names , looking at other examples like in http://www.brainxcode.cl/develop/echo.php where data is returned as a simple string... )

Help, please!!!




erik
Registered User
Quote
2016-01-16 09:23:01

Maybe something in your finishedRequest() function doesn't work. Try replacing the code with something like this:
alert('worked, data was:' + data);



sassone
Registered User
Quote
2016-01-16 10:28:13

Hello Erik,

thank you for your reply , I really appreciate!!!
I have tried wit the alert and the returned data is empty ( also data.length is 0 ) .
I am still sure the PHP is working because the dummy file is written.
I also tried to monitor network activity using chrome developer tools to see the request but this doesn't work ( and this could make sense being the canvas itself involved )
Do you know if there is any constraint on returned data format or header or whatsoever?
Anyone using ccbDoHTTPRequest has a little hint to share?

Thank you very much!!!


niko
Moderator
Quote
2016-01-16 14:41:35

That's strange, it should work. What operating system / browser and version are you using? If you open your developer console in the browser (for example in chrome, this opens when pressing CTRL+Shift+I, then click the 'Console' tab), do you see any error messages or similar?


sassone
Registered User
Quote
2016-01-17 12:09:07

Hello

thank you very much, this helped me solve it !!!!!
Actually on the console I found the error

XMLHttpRequest for http://xxy.com/index2.php required Cross Origin Resource Sharing (CORS).

And searching more on the forum I found about .htaccess file , I added it and now it's working!!!!

Thank you once again to everyone who helped


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "I?ternational" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact