0 Replies Latest reply on Jul 22, 2016 5:54 AM by GreenGoneMad

    Phonegap Desktop: $.ajax POST returning “status”:403,“statusText”:“Forbidden”

    GreenGoneMad Level 1

      Hi there,

      I'm writing a mobile app that uses AJAX. I have never used AJAX before so to see how AJAX works, I wrote a simple app that talks to asp.net page.  The app is a simple form (one text field and submit button) in which you enter an year and click submit. Ajax call is made to results.aspx.cs page on the server which returns the result and displayed on 2nd page that is inside index.html.

       

      When I run this app on using Phonegap Desktop, I'm getting http://169.254.0.2:3000/proxy/http%3A%2F%2Fmywebsite%2Fresults.aspx.cs%2FIsLeapYear 403 (Forbidden)

       

      I have added   <access origin="http://mywebsite/" /> to config.xml file. The server side file that I'm trying to access is http://mywebsite/results.aspc.cx.

       

      Can someone give me a clue as what is wrong?

       

      Here is my code:

      -----------------------------------

      $('form').submit(function(){

          var landmarkID = $(this).parent().attr('checkyear');

          var postData = $(this).serialize();

          console.log(postData);

          $.ajax({

              type: 'POST',

              data: postData+ '&amp;txtYear=' + txtYear.value,

              url: 'http://mywebsite/results.aspx.cs/IsLeapYear',

              success: function(){

                  console.log(data);

                  alert('Your comment was successfully added');

              },

              error: function(){

                  console.log(data);

                  alert('There was an error adding your comment');

              }

          });

        

          return false;

      });

      -----------------------------------

      Joe