errors using bin(this)
TypeError: request.getContent(function (result) {if (result == "0")
{Ape.log(result);cmd.sendResponse("ERR", {code: 1001, value: "User
BANNED"});return 0;} else
{Ape.log(result);cmd.user.setProperty("name",
params.name);cmd.user.setProperty("ip", cmd.ip);return 1;}}) is
undefined
and without using bind()
and using your test,
server side js gets this
TypeError: user.getProperty("name") is undefined
because inside request.getContent
the user is created and then the event adduser runs and because the
user insnt set then it get me the above error
Basically if I put a return 0; before request.getContent then the
login stops the user.. is insinde the request.getContent where it
should return but cant get it because its global scope..
On Jan 23, 2:18 pm, Erick Romero <[email protected]> wrote:
> Ok, if your are getting each APE.Log as expected 0 for Gandalf and 1 for
> Frodo, that means your APE-SERVER logic (HTTP and getContent) is working
> as expected => does allow or does not allow to past.
> Also it means that each logic-block will send the cmd.sendResponse as it
> should do for each case.
>
> When you said.. "then it goes to the page with javascript errors in both
> cases..."
> Do you mean errors in your BROWSER (login page, etc) ?
>
> If you are getting JS-errors in your SERVER that errors should be shown
> into the APE.LOG.
> Do you have errors there?
>
> About the bind error.... not sure how it is used outside Mootools. Are
> you using a mootools class in the server-side?
> What bind should do is to "bring" the hook-connect scope (i.e. variables
> "param" and "cmd") "visible" inside the getContent function..
> so you can cmd.user.setProperty without getting the undefined error
>
> On 01/23/2012 04:04 PM, utan wrote:
>
>
>
>
>
>
>
> > ok,
> > from your appointed test, if '0' run the code 'Gandalf: You will not
> > past.' if I run '1' Frodo: Run away!!
> > then the it goes to the page with javascript errors in both cases..
> > one catch .bin(this) is not working so return 0 isnt doing anything..
> > ;(
>
> > On Jan 23, 1:40 pm, Erick Romero <[email protected]> wrote:
> >> Ups... I made an mistake in the double-quotes.. fixed now:
>
> >> Try
>
> >> request.getContent(function(result){
>
> >> Ape.log('Result: "' + result + '"');
>
> >> if(result == 0){
> >> Ape.log('- Gandalf: You will not past..');
> >> cmd.sendResponse('ERR', {'code': 1001, 'value':'User
> >> BANNED'});
> >> return 0;
> >> }
> >> else {
> >> Ape.log('- Frodo: Run away!!');
> >> cmd.user.setProperty('name', params.name);
> >> cmd.user.setProperty('ip', cmd.ip);
> >> return 1;
> >> }
>
> >> }).bind(this);
>
> >> Modify your PHP file to output manually the result and make two test:
>
> >> First
> >> <?php echo '0' ?>
>
> >> Second
> >> <?php echo '1' ?>
>
> >> And let me know what your are getting in your APE log for each test.
>
> >> Note:
> >> I don't know if you are missing the point, but in your function copied
> >> below you are including
>
> >> if(result != ""){
>
> >> that means that php is sending something, so in good theory the
> >> if-inside logic should allow to past instead of send the sendResponse
> >> error
>
> >> On 01/23/2012 03:12 PM, utan wrote:
>
> >>> Erick
> >>> I have it just like you suggested and still let me go all the way..
> >>> request.getContent(function(result){
> >>> if(result != ""){
> >>> Ape.log(result);
> >>> cmd.sendResponse('ERR', {'code': 1001, 'value':'User BANNED'});
> >>> return 0;
> >>> }else{
> >>> cmd.user.setProperty('name', params.name);
> >>> cmd.user.setProperty('ip', cmd.ip);
> >>> return 1;
> >>> }
> >>> }).bind(this);
> >>> the only differences there is , is that your have a more recent build
> >>> than me, I think I have 111 or something along those lines..
> >>> I am frustrated..
--
You received this message because you are subscribed to the Google
Groups "APE Project" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ape-project?hl=en
---
APE Project (Ajax Push Engine)
Official website : http://www.ape-project.org/
Git Hub : http://github.com/APE-Project/