Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery Ajax Unauthorized 401 Error
    text
    copied!<p>I have this code:</p> <pre><code>&lt;?php $username = $_POST['username']; $password = $_POST['password']; $ck = time(); $read = new GoogleReaderAPI( $username, $password ); $token = $read-&gt;getToken(); echo "RSS Feed: &lt;input type='text' name='rss_feed' /&gt; &lt;br /&gt; "; echo "&lt;input type='hidden' value='$token' id='token' /&gt;"; echo "&lt;input type='hidden' value='$ck' id='ck' /&gt;"; echo "&lt;input type='hidden' value='$username' id='username' /&gt;"; echo "&lt;input type='hidden' value='$password' id='password' /&gt;"; echo '&lt;input type="button" value="Submit" id="click"/&gt;'; echo "&lt;div id='result'&gt;&lt;/div&gt;"; ?&gt; &lt;script&gt; jQuery("#click").click(function(){ var quickadd = escape( jQuery("input[name=rss_feed]").val() ); var T = escape( jQuery("#token").val() ); var ck = escape( jQuery("#ck").val() ); var params = "quickadd="+quickadd+"&amp;T="+T; jQuery.ajax({ type: "POST", url: "http://www.google.com/reader/api/0/subscription/quickadd?ck="+ck+"&amp;client=scroll", data: params, contentType: "application/json", success: function(data){ alert(data); } }); }); </code></pre> <p></p> <p>I'm getting a 401 Unauthorized error when using ajax but when I try to use an ordinary POST method (non-ajax), then I am able to see the output. <br> This is an exmaple ouput that i'm seeing when using an ordinary POST</p> <pre><code>{"query":"http://feeds.feedburner.com/TechCrunchIT","numResults":1,"streamId":"feed/http://feeds.feedburner.com/TechCrunchIT"} </code></pre> <p>By the way i'm integrating the google reader account in my application that is why i'm calling that one in the ajax-url.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload