javascript - jQuery cross domain post redirect -


i'm trying use jquery post form chargify. "net" tab shows 302 redirect (in red indicating error), jquery throwing 404 error. possible preform x-domain, post, redirect request browser or need use proxy?

$(function() {      var endpoint = "https://api.chargify.com/api/v2/signups"      $('#new_sub_form').on('submit', function(e){          e.preventdefault()          var jqxhr = $.ajax({             type: "post",             url: endpoint,             crossdomain:true,             data: $('#new_sub_form').serialize(),             success: function(data, textstatus, request){                 console.log(request.getresponseheader('location'));             },             error: function (request, textstatus, errorthrown) {                 console.log(request.getresponseheader('location')); // returns null             }         })     })//on('submit') })//ready() 

update (more info): realized 302 redirecting me page didn't exist on server. unfortunately once fixed this, still have issue. can tell, post chargify, send 302 browser uri specified. uri located on server (localhost now). once user redirected server parses response , returns json. tested response header location via copy , paste tab , works fine.

chargify offering https, while localhost http. cause error?! http response

ran similar problem other day. im using asp.net mvc4.

its not enough if use crossdomain:true u need add, datatype: 'json or html depending on return value', xhrfields: { withcredentials: true }, need add these headers "access-control-allow-origin:"http://yourdomain.net" , access-control-allow-credentials:true" , maybe "access-control-allow-methods:get,post" in case aswell response.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -