Ajax results in parse error
I get a parse error on one form call but not others. I'm using the same $.ajax() call on all three forms. I have googled this issue, and found some suggestions, but don't think they apply. I believe my data is formatted correctly. The response from PHP script uses json_encode. The form with the problem has calls to third party api's through cURL. The other two forms use the same calls, just different data, and no parse errors.
Any suggestions? Any other reasons that cause the parse errors? Do I need to specify contentType in the ajax call?
My example call,
- $.ajax({
- type : 'POST',
- url : '<?php echo site_url('backend/step_two/save');?>',
- timeout : 20000,
- dataType : 'json',
- data: {
- package : $('#package :selected').val(),
- website_type : $('#website_type').val(),
- payment_discount : $('#payment_discount :selected').val()
- },
- success : function(data){
- $('#waiting').hide();
- var element = $('#main-right').jScrollPane({autoReinitialise:true, verticalGutter:0, horizontalGutter:0});
- var api = element.data('jsp');
- api.scrollToY(0,'linear');
- if(data.error === false){
- $('#submit-response').html('<div id="submit-response-good">' + data.msg + '</div>').fadeIn('slow');
- setTimeout(function() { $("#submit-response").fadeOut('slow'); }, 5000);
- setTimeout(function(){ window.location = '<?php echo site_url('backend/step_three');?>' }, 6000);
- }else{
- $('#submit-response').html('<div id="submit-response-bad">' + data.msg + '</div>').fadeIn('slow');
- setTimeout(function() { $("#submit-response").fadeOut('slow'); }, 5000);
- }
- },
- error : function(XMLHttpRequest, textStatus, errorThrown) {
- $('#waiting').hide();
- var element = $('#main-right').jScrollPane({autoReinitialise:true, verticalGutter:0, horizontalGutter:0});
- var api = element.data('jsp');
- api.scrollToY(0,'linear');
- $('#submit-response').html('<div id="submit-response-bad">'+textStatus+'</div>').fadeIn('slow');
- setTimeout(function() { $("#submit-response").fadeOut('slow'); }, 5000);
- }
- });
-
- $('.successmsg').css('display','none');
- return false;
PHP response:
- $return['error'] = true;
- $return['msg'] = 'Authorization failed';
- echo json_encode($return);