How to use CHARSET correctly in Angularjs

Asked

Viewed 788 times

2

I’m starting at Angular and I have a basic question.. When I pass data from one form to another presentation screen, the accented characters are being presented all messed up. Please help me identify why the script below is not working.

		var config = {
                headers : {
                    'Content-Type': 'application/json;charset=iso-8859-1'
                }
            }
				$http.post('views/protected/apresenta_result.php', data, config)
		        .success(function(data, status, headers, config)
		        {
					sucesso();
		        })
		        .error(function(data, status, headers, config)
		        {
		            console.log('error');
					erro();
		        });

1 answer

2

You need to set a Accept in the header.

Accept: application/json;charset=UTF-8
Accept-Charset: UTF-8
    var config = {
                headers : {
                    'Accept': "application/json;charset=utf-8',
                    'Accept-Charset':"charset=utf-8',
                    'Content-Type': 'application/json;charset=iso-8859-1'
                }
            }
                $http.post('views/protected/apresenta_result.php', data, config)
                .success(function(data, status, headers, config)
                {
                    sucesso();
                })
                .error(function(data, status, headers, config)
                {
                    console.log('error');
                    erro();
                });

Browser other questions tagged

You are not signed in. Login or sign up in order to post.