Bonjour

Bon c'est un problème connu, mais cela fait 3 heures que je cherche et aucunes réponses données sur le net fonctionnent.

FF quoi que je lui mets comme content-type de la réponse JSON cela fonctionne, IE si je lui mets comme content-type application/json , text/json, text/javascript, application/x-json, application/x-www-form-urlencoded, ... et j'en passe tellement j'ai essayé de combinaisons cela fonctionne, mais il me propose de télécharger le fichier.

La seule différence est que si je lui dit que c'est du javascript il me rajoute l'extension js au fichier à télécharger. Il est gentil hein! Merci Microsoft.

Et si je lui mets text/html ou text/plain comme je l'ai vu proposer maintes fois comme solutions ça ne fonctionne pas il m'affiche une page blanche avec en haut mon code JSON.

Comment supprimer cette proposition de télécharger le fichier?

Voici mon code :
javascript (jQuery) :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function show_formation(link){
        //alert(link.href);
        $('#ajax-loader').remove();
        $.ajax({
            type: "POST",
            url : link.href,
            dataType: 'json',
            contentType: "application/json",
            //contentType: "application/x-www-form-urlencoded;charset=utf-8",
            success : function(json){
                        $('#ajax-loader').remove();
                        $.each( json, function( key, value ) {
                            //alert( key + ": " + value
                            $('#'+key).val(value);
                        });
                        $('li.hide').removeClass('hide');
                        $('#tabform a[href="#fiche"]').tab('show');
                    }
            });
        return false;
    };
php (CodeIgniter) :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
function fiche_Formation($idform){
            $this->db->select("LIBELLE, DESCRIPTION, THEME_FORMATION, ORGANISME_FORMATION, TYPE, MODULE");
            $arrayform = $this->db->get_where($this->table, array('ID' => $idform))->row_array(0);
            $this->output
                ->set_header("Cache-Control: no-store, no-cache, must-revalidate")
                ->set_content_type('text/json')
                ->set_output(json_encode($arrayform));
        }
J'en suis à me dire que je vais renoncer au JSON.

Merci de m'aider