Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7757099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:59:42+00:00 2026-06-01T12:59:42+00:00

Updated: Thank you Rob W for pointing out there was nothing wrong with the

  • 0

Updated: Thank you Rob W for pointing out there was nothing wrong with the code. An error in the backend was found where CHARSET was not yet defined when passing the header(). IE is sensitive about this while Chrome and FF isn’t.

This case can be used for AJAX calls on platforms with dynamic charset support.

—————–

[The original post]

I thought jQuery sorted out browser differences for us. I have absolutely no idea why this works flawlessly in Chrome and FF but not IE.

In Chrome and FF:

The script posts an iso-8859-1 encoded ajax request perfectly. The result is iso-8859-1 encoded and returns nicely.

In IE9

In the backend, depending on the header of (get_address.json.php), I get different results:

// Throws readyState 0 error in IE.
header('Content-type: application/json; charset=iso-8859-1');

// Works in IE9 but strips foreign characters.
header('Content-type: application/json; charset=utf-8');

// Same result as utf-8 above
header('Content-type: application/json');

The script:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
  $(document).ready(function() {
    $("input:button[name=get_address]").click(function() {
      $.ajax({
        url: "get_address.json.php",
        type: "POST",
        data: $("input:text[name=crn]").serialize(),
        cache: false,
        async: false,
        dataType: "json",
        beforeSend: function(xhr) {
          xhr.overrideMimeType("application/x-www-form-urlencoded; charset=<?php echo CHARSET; ?>");
        },
        error: function(jqXHR, textStatus, errorThrown) {
          alert(jqXHR.readyState + '\n' + textStatus + '\n' + errorThrown.message);
        },
        success: function(data) {
          if (!data) {
            alert("Error: No response");
            return;
          }
          if (data.error) {
            alert(data.error);
            return;
          }
          $("input:text[name=firstname]").val(data.firstname);
          $("input:text[name=lastname]").val(data.lastname);
          $("input:text[name=street_address]").val(data.street);
          $("input:text[name=postcode]").val(data.postcode);
          $("input:text[name=city]").val(data.city);
        },
        complete: function() {}
      });
    });
  });
</script>

<input type="text" name="crn"> <input type="button" name="get_address" value="Get Address" />

Simulated JSON response (with ISO-8859-1 foreign characters):

<?php
header('Content-type: application/json; charset='. CHARSET);
echo '{"census":"1","protected":"0","crn":"19000000-1234","firstname":"Åke","lastname":"Jönsson","co":"","street":"Testvägen 1","postcode":"72344","city":"Göteborg"}';
?>

The error alert() in IE says:

[object Error]
error
[object Error]

I don’t fancy solutions like converting charsets unless this is the only solution possible. The backend is osCommerce and is purely iso-8859-1.

How can we prevent throwing an error for iso-8859-1 content without character conversion?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:59:43+00:00Added an answer on June 1, 2026 at 12:59 pm

    Make sure the called script returns a valid content-type charset.

    <?php
    // make sure CHARSET is defined before output.
    header('Content-type: application/json; charset='. CHARSET);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: I've updated the code below so that it now works, thanks to Rob's
Code is read more often then updated. Writing more readable code is better than
In xCode 3.2.3 (haven't updated to 4.1 yet) under Active Configurations I have: Debug,
I know this is an easy question, I am just not getting something...so thank
UPDATED: This is totally wrong assumption. I retested it and sure enough I was
I updated my project, written tons of code and after that i updated again.
I recently updated to PHP 5.3.6 and there were some deprecated functions and INI
I was wondering if there is a better way to write my code below.
I have updated the code I am working on here http://jsfiddle.net/dFfJm/ At the first
Edit1: Updated my method. I think it helped... I wont be able to be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.