jquery - data.success undefined -


working on submission form ajax, json , php. data handled db, script, alert(data.success), says data.success undefined. if alert(data), shows need there {"success":"http:\/\/myaddress.com"}

function confirmsubmit() { $.ajax({     type: 'post',     url: 'index.php?route=payment/authorize/send',     data: $('#authorize :input'),        beforesend: function() {         var img = '<?php echo $text_wait; ?>';         $('#authorize_button').attr('disabled', 'disabled');          $('#authorize').before('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> ' + img + '</div>');         alert('start');     },     success: function(data) {         if (data.error) {             alert('errors...');             alert(data.error);              $('#authorize_button').attr('disabled', '');         }          $('.wait').remove();          if (data.success) {             alert('success! should redirect.');             location = data.success;         }         else {             alert('it worked... won\'t redirect...');             alert(data.success);         }      } }); alert('end'); 

}

you don't parse response. data still string.

set datatype: 'json' in $.ajax options.

even better if set right content type response in php:

header('content-type:  application/json.'); 

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -