1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| // transformation de la variable json en varaible text
var myObject2 =
{ "Itineraire" :
{ "nom" : "Iti-1",
"Etapes" :
[
{ "nom" : "etape-1",
"Coordonnees":
[
{"lat" : 1, "lng" : 1, "typepoly" : 0},
{"lat" : 2, "lng" : 2, "typepoly" : 0},
{"lat" : 3, "lng" : 3, "typepoly" : 0},
{"lat" : 4, "lng" : 4, "typepoly" : 1},
{"lat" : 5, "lng" : 5, "typepoly" : 0}
]
},
{ "nom" : "etape-2",
"Coordonnees":
[
{"lat" : 1, "lng" : 1, "typepoly" : 1},
{"lat" : 2, "lng" : 2, "typepoly" : 1},
{"lat" : 3, "lng" : 3, "typepoly" : 1},
{"lat" : 4, "lng" : 4, "typepoly" : 1},
{"lat" : 5, "lng" : 5, "typepoly" : 0}
]
}
]
}
};
strjson = JSON.stringify(myObject2);
$(document).ready(function(){
$("#bouton").click(function(){
$.ajax({
type: "POST",
//dataType: "json",
//processData: false,
url: "php/traitement.php",
data: {"json": strjson},
error: function(msg){ alert( "Error !: " + msg );},
success: function(data){
//affiche le contenu du fichier dans le conteneur dédié
//$('#contenu_fichier_ajax').css({display:"none"});
/*$('#contenu_fichier_ajax').text(data).show("slow");*/
$('#contenu_fichier_ajax').append(data).show("slow");
//$('#contenu_fichier_ajax').css({color:"green", display:"block"});
}});
});
}); |
Partager