$.ajax({ type: 'POST', url: 'http://tutorial101.blogspot.com/feed/', data: { postVar1: 'theValue1', postVar2: 'theValue2' }, beforeSend:function(){ // this is where we append a loading image $('#ajax-panel').html(''); }, success:function(data){ // successful request; do something with the data $('#ajax-panel').empty(); $(data).find('item').each(function(i){ $('#ajax-panel').append('' + $(this).find('title').text() + '
' + $(this).find('link').text() + '
'); }); }, error:function(){ // failed request; give feedback to user $('#ajax-panel').html('Oops! Try that again in a few moments.
'); } });
article
Saturday, August 23, 2014
The Perfect AJAX Request
Wednesday, August 20, 2014
Running Python Scripts on Windows with Apache and Xampp
Running Python Scripts on Windows with Apache and Xampp
create a script like the following, and put it in c:\xampp\cgi-bin\tutorial_1.py
URL = http://localhost/cgi-bin/tutorial_1.py
create a script like the following, and put it in c:\xampp\cgi-bin\tutorial_1.py
#!/Python27/python print "Content-type: text/html" print print "<html>" print "<head>" print "<title>Tutorial CGI</title>" print "</head>" print "<body>" print "<h1>Phython!</h1>" print "<p>Xampp</p>" print "<p>Tutorial101</p>" print "<p>Phython for web</p>" print "</body>" print "</html>"
URL = http://localhost/cgi-bin/tutorial_1.py
Tuesday, August 19, 2014
Creating a RESTful Web Service in PHP
Creating a RESTful Web Service in PHP
<? // process client request via url header("Content-Type:application/json"); if (!empty($_GET['name'])) { $name = $_GET['name']; $price = get_price($name); if (empty($name)) deliver_response(200,"book not found", null); else deliver_response(200,"book found", $price); }else{ deliver_response(400,"Invalid request", null); } function deliver_response($status,$status_message,$data) { header("HTTP/1.1 $status $status_message"); $response['status'] = $status; $response['status_message'] = $status_message; $response['data']=$data; $json_response = json_encode($response); echo $json_response; } function get_price($find) { $books=array( "java" =>299, "c" =>348, "php" =>267 ); foreach ($books as $book=>$price){ if ($book==$find) { return $price; break; } } } ?>
//.htaccess file # Turn on the rewrite engin Options +FollowSymLinks RewriteEngine On #request routing RewriteRule ^([a-zA-Z]*)$ index.php?name=$1 [nc,qsa]
Subscribe to:
Posts (Atom)