Results 1 to 3 of 3
  1.    #1  
    Code:
          url = "http://8tracks.com/sessions.json";
    
          var userName = "remi";
          var passWord = "good";
          var postdata = {
                login: userName,
                password: passWord
          };
          var myAjax = new Ajax.Request(url, {
             method: 'POST',
             evalJSON: 'force',
             postBody: postdata,
             contentType: 'application/x-www-form-urlencoded',
             onComplete: onComplete,
             onFailure: onFailure
          });
    The code is returning a login error about credentials.

    Here is the php code that works for login that works:
    Code:
       function login($username, $password) {
          //cURL login info to 8tracks to authenticate
          $url = "http://8tracks.com/sessions.json"; 
          $postData_8tracks = array(
              'login' => $username,
              'password' => $password
             );
    
          $ch = curl_init();
          curl_setopt($ch,CURLOPT_URL,$url);
          curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
          curl_setopt($ch,CURLOPT_CONNECTTIMEOUT, 5);
          curl_setopt($ch,CURLOPT_POST, 1);
            curl_setopt($ch,CURLOPT_POSTFIELDS, $postData_8tracks);
          //curl_setopt($ch, CURLOPT_WRITEFUNCTION, 'curlCallback');
          $result = curl_exec($ch);
          curl_close($ch);
    
          //return json data
          echo $result;
       }
    it uses cURL.
    this is what i'm suppost to post to:

    Code:
    curl -u remi:bad --request POST -d "" http://8tracks.com/sessions.xml
    Anyone know how to get this working using Ajax.Request 'POST'?
  2. #2  
    Try changing:

    Code:
          var postdata = {
                login: userName,
                password: passWord
          };
    to:

    Code:
          var postdata = "login=" + userName + "&password=" + passWord;
    Arthur Thornton

    Former webOS DevRel Engineer at Palm, HP, and LG
    Former webOS app developer (built Voice Memos, Sparrow, and several homebrew apps and patches)
    Former blogger for webOS Nation and webOS Roundup
  3.    #3  
    Thanks!

    I didn't think it was working at first because the example login info was bogus... Wasted about 10 minutes!

Posting Permissions