Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using Ajax jQuery for chargify it showing 404 error,
If any one knows kindly please tell me the solution to resolve the issue.


Firebug console
---------------
NetworkError: 404 Not Found - https://xxx.chargify.com/subscriptions.json"

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://xxx.chargify.com/subscriptions.json. This can be fixed by moving the resource to the same domain or enabling CORS.


My code
-------
JavaScript
$.ajax( {
                            url: 'https://xxx.chargify.com/subscriptions.json',
                           type: 'POST',
                           contentType: 'application/json',
                            dataType: "json",
                           crossDomain: true,
                           data: JSON.stringify(dataser),
                           beforeSend: function (xhr) {
                               xhr.setRequestHeader('Authorization', make_base_auth('username', 'password'));
                               xhr.setRequestHeader("Access-Control-Allow-Origin", "*"); 
                               xhr.setRequestHeader("Access-Control-Allow-Headers", "Content-Type"); 
                            },  
                            success: function(data) {
                                 console.log(JSON.stringify(data));
                            },
                            error: function(data) {
                              alert("errorrequest"+JSON.stringify(data));
                            }
                      });
Posted
Updated 29-Jun-15 21:57pm
v3
Comments
F-ES Sitecore 30-Jun-15 4:36am    
Have you at least googled your error message and gone through the solutions of the millions of people who have also had this problem? You are adding the control headers to your request, if the client could simply bypass security mechanisms by amending their code they wouldn't be very effective mechanisms. You need to add those headers to the response that is coming from your target url.

If you consult the chargify documentation or support I'm sure they'll explain the correct process to call their services.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900