File tree Expand file tree Collapse file tree 2 files changed +63
-0
lines changed
Expand file tree Collapse file tree 2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ if ((isset ($ _SERVER ['HTTP_X_REQUESTED_WITH ' ]) && $ _SERVER ['HTTP_X_REQUESTED_WITH ' ] == 'XMLHttpRequest ' )) {
4+ //var_dump($_POST);
5+ print json_encode (array ("firstName " =>'its-true ' ));
6+
7+ }
8+
9+
10+ ?>
Original file line number Diff line number Diff line change 1+ <!--
2+ To change this template, choose Tools | Templates
3+ and open the template in the editor.
4+ -->
5+ <!DOCTYPE html>
6+ < html >
7+ < head >
8+ < title > </ title >
9+ < meta http-equiv ="Content-Type " content ="text/html; charset=UTF-8 ">
10+ < script type ="text/javascript " src ="../resources/js/jquery-1.6.4.js "> </ script >
11+ < script language ="javascript ">
12+ $ ( function ( ) {
13+ /*
14+ var deferred = $.Deferred();
15+ deferred.resolve("hello world");
16+ deferred.done(function(value) {
17+ alert(value);
18+ });
19+ */
20+ var ajax_url = 'ajax.php' ;
21+ /*
22+ var post = $.ajax({
23+ url: ajax_url,
24+ data: {json: JSON.stringify({firstName: "Jose", lastName: "Romaniello"})} ,
25+ type: "POST"
26+ });
27+
28+ post.done(function(p){
29+ alert(p.firstName + " saved.");
30+ });
31+
32+ post.fail(function(){
33+ alert("error!");
34+ });
35+ */
36+
37+ var post = $ . post ( ajax_url ,
38+ {
39+ json : JSON . stringify ( { firstName : "Jose" , lastName : "Romaniello" } )
40+ }
41+ ) . pipe ( function ( p ) {
42+ return "Saved " + p . firstName ;
43+ } ) ;
44+
45+ post . done ( function ( r ) { alert ( r ) ; } ) ;
46+
47+ } ) ;
48+ </ script >
49+ </ head >
50+ < body >
51+ < div > jQuery Resolved</ div >
52+ </ body >
53+ </ html >
You can’t perform that action at this time.
0 commit comments