Category Archives: AJAX

Part 3: Real-time Applications with AngularJS and Java

Real-time Applications with AngularJS and Java – Part 3
// Java Code Geeks

1. Introduction This article is the last one of a series of three on real-time applications. In the part 1, I have created a simple Task management application and implemented the Periodic Refresh AJAX pattern to make it feel as if the UI was updated in real-time when tasks were created. In the part 2,

How to Use NumericUpDown Control Of Ajax In ASP.NET Using C#

How to Use NumericUpDown Control Of Ajax In ASP.NET Using C#
// C-Sharpcorner Latest Articles

In this article we will learn about how to use NumericUpDown control of Ajax in ASP.NET using C#.

AngularJS AJAX calls

AngularJS AJAX calls
// Kogonuso

AngularJS is a JavaScript framework that allows us to create Single Page Applications (SPA). If we use AngularJS we can bind from our HTML views to JavaScript files (controllers). Controllers will offer the data to the view. Typically this data is retrieved from REST services using Ajax calls. The goal of this post is to show how to make AJAX calls using AngularJS. I will illustrate two different ways to do it, the first one helps to understand how the asynchronous call works, the second one is an easier way to do it using a higher-level service.

Using $http and $q

One way to make AJAX calls using AngularJS is using the services $http and $q:

  • The $http service allows us to make the GET and POST calls.
  • The $q service is used to wait asynchronously for the response, basically it is a deferred result, it returns a “promise” that will response after some time. After some time the deferred can be “resolved” or “rejected”. The method using this deferred can add two call-backs to it one to execute when it is resolved and one when it is rejected.

Let say we have a controller that needs to populate some data asynchronously. I like to dedicate the controller to define the binds for our views. The AJAX call will be executed in a different file, a repository.
AngularJS – Controller: The module will call a repository and add set the response in the scope when the deferred is resolved.
angular js controller
AngularJS – Repository: The repository make an AJAX Get request to a ASP.NET WebAPI Controller.
angular js repository
We can write the same repository with less lines using shortcut methods:
angular js repository
This solution works but there is an easier way to do AJAX calls…

Using $resource

This service lets us interact with RESTful server-side data sources with a higher-level than the $http service. The $resource service is defined in the module ‘ngResource’ and this module is in the file angular-resource.js.
The first thing that we need to do is to reference the angular-resource.js file and add this module as a dependency of our module:
ngResource reference
ngResource reference
Using the $resource we can write our controller and repository easier because we don’t have to deal directly with deferred objects.
This is now the implementation of our controller and repository using the Angular service $resource , really easy!
angular js repository and controller
About these ads

Building a Bootstrap Contact Form Using PHP and AJAX

via Building a Bootstrap Contact Form Using PHP and AJAX – Tuts+ Web Design Tutorial.

In this tutorial I’ll go over the steps to create a working contact form, utilising the ever popular front-end framework Bootstrap, in combination with AJAX and PHP. From there we can explore some additional features such as some fancy CSS animation with animate.css, further validation in JavaScript and refining the user experience with asynchronous content.

At the time of writing Bootstrap 3.3.5 is the most current version, and it’s worth mentioning that we are using a default build of Bootstrap (with a 12 column layout) for this tutorial. When following along make sure you use the latest snippets and code structures as outlined by the Bootstrap documentation.

JQuery AJAX Example

via jQuery AJAX Example | Web Code Geeks.

The aim of this example is to give you a full understanding of AJAX, which stands for Asynchronous Javascript and XML. Ajax is not a programming language or a tool, but a concept.

Ajax is a client-side script that communicates to and from a server/database without the need for a postback or a complete page refresh.

The best definition for Ajax would be “the method of exchanging data with a server, and updating parts of a web page – without reloading the entire page.”

Ajax itself is mostly a generic term for various JavaScript techniques used to connect to a web server dynamically without necessarily loading multiple pages. In a more narrowly-defined sense, it refers to the use of XmlHttpRequest objects to interact with a web server dynamically via JS.

GWT JSNI Example

via GWT JSNI Example | Examples Java Code Geeks.

In this example we will learn about GWT JSNI. The Google Web Toolkit is a development framework for creating Ajax-enabled web applications in Java. Tools and technologies used in this example are Java 1.8, Eclipse Luna 4.4.2, Eclipse GWT Plugin 2.6

Session Timeout Handling on JSF AJAX request

via Programming Peacefully: Session Timeout Handling on JSF AJAX request.

When we develop JSF application with AJAX behaviour, we may experience the problem in handling timeout scenario of Ajax request. For example, if you are using J2EE Form-based authentication, a normal request should be redirected to the login page after session timeout. However, if your request is AJAX, the response could not be treated properly on the client-side. User will remain on the same page and does not aware that the session is expired.

Many people proposed solution for this issue. The followings are two of possible solutions involve the use of Spring security framework:
1. Oleg Varaksin’s post
2. Spring Security 3 and ICEfaces 3 Tutorial