Adefinir
1
app
Models
scripts
main_test.php
Go to the documentation of this file.
1
<?php
2
/*
3
=================================
4
BOUTONS GESTION EMPLOYES
5
<button type="button" value="job" onclick="hire(this)"> Click Me </button>
6
7
function hire(ref) {
8
$.ajax( {
9
url: "App:\Models\ajax_requests.php",
10
type: "POST",
11
data: {function: "hire", jobName: String( $(ref).val() );
12
}
13
})
14
}
15
16
function fire(ref) {
17
$.ajax( {
18
url: "App:\Models\ajax_requests.php",
19
type: "POST",
20
data: {function: "fire", jobName: String( $(ref).val() )}
21
})
22
}
23
24
25
================================
26
27
BOUTONS ACTIONS
28
29
var actions = [];
30
31
<button type="button" id="action" value="dev_bugs" onclick="actions(this)"> Click Me </button>
32
33
$(document).ready(function(){
34
$("#action").click(function(){
35
actions.push( $(this).val() );
36
37
});
38
});
39
40
41
42
43
<p id="showActions"><p>
44
45
function showActionsList() {
46
var res = "";
47
for(var i = 0; i < actions.length; i++) {
48
res += actions[i];
49
if ( i != (actions.length-1) )
50
res += ", ";
51
}
52
$("#showActions").html(res)
53
}
54
55
56
57
58
=============================
59
BORDEL
60
61
$(document).ready(function(){
62
$("#mytable1").show();
63
$("#mytable2").hide();
64
65
$("#button1").click(function(){
66
$("#text").html("Default List Name");
67
$("#mytable2").hide();
68
$("#mytable1").show();
69
70
});
71
72
$("#button2").click(function(){
73
$("#mytable1").hide();
74
$("#mytable2").show();
75
$("#text").html("Second List Name");
76
});
77
});
78
79
80
81
<script>
82
function create () {
83
$.ajax({
84
url:"test.php", //the page containing php script
85
type: "post", //request type,
86
dataType: 'json',
87
data: {registration: "success", name: "xyz", email: "abc@gmail.com"},
88
success:function(result){
89
console.log(result.abc);
90
}
91
});
92
}
93
</script>
94
95
96
97
<button type="button" onclick="create()">Click Me</button>
98
99
var btn_val = $(this).val();
100
101
102
103
$registration = $_POST['registration'];
104
$name= $_POST['name'];
105
$email= $_POST['email'];
106
107
if ($registration == "success"){
108
// some action goes here under php
109
echo json_encode(array("abc"=>'successfuly registered'));
110
}
111
112
113
114
115
$.ajax({ url: '/my/site',
116
data: {action: 'test'},
117
type: 'post',
118
success: function(output) {
119
alert(output);
120
}
121
});
122
123
124
125
if(isset($_POST['action']) && !empty($_POST['action'])) {
126
$action = $_POST['action'];
127
switch($action) {
128
case 'test' : test();break;
129
case 'blah' : blah();break;
130
// ...etc...
131
}
132
}
Generated by
1.8.20