Reputation: 1806
I know that similar issues where discussed earlier on this page, but none actually solved the issue on the Laravel platform.
I'm having issues with AJAX responses and special charactors, when I open the response URL in the browser the special charactors are displayed properly. The same charactors from the same database data set displayed in the page without AJAXing are displayed correct.
Here is my relevant code (already modified according to other similar issues on different platforms):
// Ajax call to add to myevents section
public function addtomyeventsform($eventid){
$responseArray = array('eventid'=>$eventid);
$response = Response::view('ajax/sportevent_myevent_add',$responseArray)->header('Content-type','text/html; charset=utf-8');
return $response; // utf8_encode($response); // that actually made it worse: 4 squares instead of 2 per charactor
}
Preview in Chrome:
I don't understand what is happening here. Anyone can point me in the right direction? Is this Laravel related?
Addition
As requested here is the JavaScript code.
function addtomyevents(eventid){
var ajax_url = '/addtomyevents/'+eventid;
console.log (ajax_url);
$('body').css('overflow','hidden');
$('body').css('padding-right','10px');
$('#form_center').removeClass('hide');
$('#form_loader').removeClass('hide');
$.ajax( {
url:ajax_url,
beforeSend: function( xhr ) {
xhr.overrideMimeType( "text/plain; charset=x-user-defined" );
}
}).done(function(data) {
$('#form_container').html(data);
$('#form_loader').addClass('hide');
$('#form_container').show('blind', 500);
setDetailsbutton();
trackAjax(ajax_url);
});
}
Upvotes: 0
Views: 1015
Reputation: 44526
When sending the AJAX request from your addtomyevents
function in the js/ha_allviews.js
file you have a closure for beforeSend
. Remove it and it should work:
$.ajax( {
url:ajax_url,
}).done(function(data) {
$('#form_container').html(data);
$('#form_loader').addClass('hide');
$('#form_container').show('blind', 500);
setDetailsbutton();
trackAjax(ajax_url);
});
Upvotes: 2