salut,
navigateur web : chrome
index.html --- POST ---> page1.php --- lien ---> page2.php
1) index.html contient un formulaire qui poste vers page1.php
2) page1.php contient un lien vers page2.php
3) page1.php contient un appel ajax vers ajax.php
probleme : si on revient de la page2.php vers la page1.php (en faisant "back" avec le navigateur, on en cliquant sur "javascript:history.back()"), et si on recharge ensuite la page (F5), l'appel ajax va deconner, erreur sans message (chaines vides) dans la console. les rechargements ulterieurs fonctionneront normalement, y'a que le premier qui deconne, et ca m'enerve...
index.html :
Code html : 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 <html> <head> </head> <body> index <form method="post" action="page1.php"> <input type="submit"> </form> </body> </html>
page1.php :
Code html : 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
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 <html> <head> <script src="jquery-1.10.2.min.js" type="text/javascript"></script> <script type="text/javascript"> function call_ajax() { $.ajax ( { type: "POST", url: "ajax.php", success: function( response ) { console.log( response ); }, error: function (xhr, ajaxOptions, thrownError) { console.log( '%o', xhr ); console.log( '%o', xhr.responseText ); console.log( '%o', thrownError ); } } ); } $( document ).ready(function() { call_ajax(); }); </script> </head> <body> page 1 <a href="page2.php">page2</a> </body> </html>
page2.php :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 <html> <head> </head> <body> page 2 <a href="javascript:history.back()">back</a> </body> </html>
ajax.php :
Code php : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14 <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); ini_set('error_reporting', E_ALL); header('Cache-Control: no-cache, must-revalidate'); header('Content-type: application/json'); $r = array( 'message' => 'one two one two, this is a test' ); echo json_encode( $r ); ?>
Partager