Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- in summary, 3 things:
- 0. set the request headers, application/json may or may not be needed
- 1. make sure you enter the REST-API-KEY not the Javascript key
- 2. 'quote' the JSON structure, else you get an invalid JSON, 400 message
- -->
- var serverUrl = 'https://api.parse.com/1/classes/Test';
- alert("before ajax");
- $.ajax({
- type: "POST",
- url: serverUrl,
- beforeSend: function(request) {
- request.setRequestHeader("X-Parse-Application-Id", 'MY-APP-ID');
- request.setRequestHeader("X-Parse-REST-API-Key", 'MY-REST-API-KEY');
- request.setRequestHeader("Content-Type","application/json");
- },
- data: '{"Sport":"Cricket","Comment":"super popular"}',
- success: function(msg){
- alert('yay' + JSON.stringify(msg));
- },
- error: function(msg){
- alert('boo' + JSON.stringify(msg));
- }
- });
- alert("executed parsePost");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement