Jquery代码
$.ajax({
url: '/ad_creation/get_campaign_objective/'+id,
dataType: 'text',
success: function(response) {
var campaign_objective = 'Error. Please refresh and try again.';
if (response == 'WEBSITE_CONVERSIONS')
campaign_objective = response;
if (response == 'WEBSITE_CLICKS')
campaign_objective = response;
$('select[name=campaign_objective]').val(response).hide();
$('#existing-campaign-objective').html(campaign_objective).show();
$('#campaign-objective-select').show();
if (campaign_objective == 'WEBSITE_CONVERSIONS'){
// Show pixel block again.
$('#select-pixel').show();
}
hideAjaxLoader('existing-campaign-loader');
},
error: function(xhr, ajaxOptions, thrownError) {
console.log('Invalid response', thrownError, xhr, ajaxOptions);
hideAjaxLoader('existing-campaign-loader');
}
});
Angularjs代码
$http({
method:'get',
dataType:'text',
url:'/ad_creation/get_campaign_objective/'+Number(id)
})
.success(function(data){
console.log(data);
})
我收到错误意外的令牌w。我也尝试过不将id转换为数字,但仍然会收到错误。
答案 0 :(得分:0)
检查响应标头的content-type
。
如果是'application / json'norner试图解析响应。
错误可能是因为它。