Results 1 to 8 of 8
  1. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #1  
    If I navigate to https://nikerunning.nike.com/nikeplu...erate_pin.jsp? or http://secure-nikerunning.nike.com/n...erate_pin.jsp? I get the message

    <plusService>
    <status>failure</status>
    <serviceException errorCode="RequestParametersError">login and password are required</serviceException>
    </plusService>
    However, using this code:

    Code:
    <html>
    <head>
    <title>Prototype examples</title>
       <script type="text/javascript" 
       src="/javascript/prototype.jsjsjs&$quot$;&$gt$;
       &$lt$;/$script$&$gt$;
    &$lt$;$script$&$gt$;
    
    $function$ $SubmitRequest$()
    {
    
      
      $new$ $Ajax$.$Request$('$https$://$secure$-$nikerunning$.$nike$.$com$/$nikeplus$/$v1$/$services$/$widget$/$generate_pin$.$jsp$?', {
      $method$: '$get$',
      $onSuccess$: $successFunc$,
      $onFailure$:  $failureFunc$
      });
     
    }
    
    $function$ $successFunc$($response$){
       
    
            $alert$($response$.$status$);
        
        $var$ $container$ = $('$notice$');
        $var$ $content$ = $response$.$responseText$;
        $container$.$update$($content$);
    }
    
    $function$ $failureFunc$($response$){
    
         $alert$(&$quot$;$Call$ $is$ $failed$&$quot$; );
        
    }
    &$lt$;/$script$&$gt$;
    &$lt$;/$head$&$gt$;
    
    &$lt$;$body$&$gt$;
    
      &$lt$;$p$&$gt$;$Click$ $submit$ $button$ $to$ $see$ $how$ $current$ $notice$ $changes$.&$lt$;/$p$&$gt$;
      &$lt$;$br$ /&$gt$;
     
      &$lt$;$div$ $id$=&$quot$;$notice$&$quot$;&$gt$;$Current$ $Notice$&$lt$;/$div$&$gt$;
      &$lt$;$br$ /&$gt$;
      &$lt$;$br$ /&$gt$;
      &$lt$;$input$ $type$=&$quot$;$button$&$quot$; $value$=&$quot$;$Submit$&$quot$; $onclick$=&$quot$;$SubmitRequest$();&$quot$;/&$gt$;
    
    &$lt$;/$body$&$gt$;
    &$lt$;/$html$&$gt$;
    My 'notice' DIV gets populated with a blank string. The same is happening if I use the HTTP or HTTPS links. In Firebug successFunc is firing with a response.status of 0 and a readystate of 4. Is there anything missing fro the above code as to why I am not getting the error response from the Nike+ service?

    Thanks
  2. cube660's Avatar
    Posts
    57 Posts
    Global Posts
    58 Global Posts
    #2  
    You have to bind your callbacks.
    So...
    onSuccess: successFunc,
    onFailure: failureFunc

    Becomes....

    OnSuccess: this.sucesssFunc.bind(this);
    OnFailure: this.failureFunc.bind(this);

    Hope this helps.
  3. drnull's Avatar
    Posts
    570 Posts
    Global Posts
    571 Global Posts
    #3  
    Also, you can't use alert. Try Mojo.Log.error instead.
  4. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #4  
    I haven't gone as far as the emulator or the device yet, this is just being tested in the browser. I'm hitting successFunc OK, but the response is blank and the status is 0, as opposed to 200 which I would have expected
  5. #5  
    You may want to try it out in the emulator. Regular browsers usually have more security surrounding javascript and what the ajax call can do. Most of the time, a browser will restrict a page's javascript so that it can only communicate with its home domain (the domain it was served from).
  6. cube660's Avatar
    Posts
    57 Posts
    Global Posts
    58 Global Posts
    #6  
    If your success callback is landing, and your responseText is good, what more is there, that you need?

    With prototype, a successful response status code, could either be 0, 200, or 201 etc..
  7. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #7  
    Quote Originally Posted by cube660 View Post
    If your success callback is landing, and your responseText is good, what more is there, that you need?

    With prototype, a successful response status code, could either be 0, 200, or 201 etc..
    That's my problem, the callback is landing, but the responseText is blank, whereas in a browser I get an error message in XML
  8. ldj
    ldj is offline
    ldj's Avatar
    Posts
    256 Posts
    Global Posts
    264 Global Posts
       #8  
    Quote Originally Posted by whatsit2002 View Post
    You may want to try it out in the emulator. Regular browsers usually have more security surrounding javascript and what the ajax call can do. Most of the time, a browser will restrict a page's javascript so that it can only communicate with its home domain (the domain it was served from).
    Ah right, OK. Didn't know that. Thanks.
    I'll try it out on a machine with the SDK installed and see if that makes a difference.

Tags for this Thread

Posting Permissions