AJAX can be used to create more or make interactive
applications. To start developing AJAX with PHP you will need to know about AJAX PHP example code and other important points.
One of the examples in AJAX PHP can also demonstrate the way web page
communicates with web server when users type the character into input field.
PHP AJAX Tutorial: from jQuery AJAXstart until Loading the Followers
·
Start jQuery AJAX
The first point in this tutorial is about jQuery AJAXstart. The method of jQuery AJAX could
be said as more simple in term of the way to handle HTTP request. If this
method is compared with when you code in the standard JavaScript, you might be
stuck in the method of XMLHttpRequest. But with the method of jQuery AJAX, you
will have large documentation index that explains each option within the
variety. First, you create new page along with related stylesheet. You also
download local jQuery copy along with blank JavaScript. Then, you combine two
code bits from your HTML located in different page sections.
·
Return JSON data
In order to return JSON
data in PHP, you may want to load the full followers list dynamically on
users’ profile. To make it clear, let’s put simple example. The person has
eighteen followers, but only ten followers are displayed by default. In this
example, each click is going to load more around five followers until you have
loaded all of them. You probably do not want to return the data as plaintext.
Instead, you prefer to use application/JSON as the JSON data. This format can
make jQuery loop easily through followers and append the followers into a list.
·
Load the followers in AJAX
The PHP response will be held in JS variable which is
called as json. You then turn every array object located inside the string of
json into new variable known as item. In this basic example, there are only two
keys owned by the objects including item.username and item.profile_pic. One
aspect which might be possibly confusing in the loop is the logic check used on
each item. In term of loading followers with AJAX
PHP, there is the value handled differently to be used for building new
button of load more followers. The HREF attribute of new button which is passed
back into PHP loads followers’ next set.
·
The support of AJAX in Struts2
Struts 2 uses the library of Toolkit Dojo in order to
provide support for AJAX. In drop down of Struts2 AJAX, the first step is
adding the JAR file. The second step is creating action class of AJAX. This is
related to AJAX call Struts2 action example.
You create action class that is going to be called for AJAX example. After
that, you create JSP and struts.xml entry.
·
The change of PHP setting
When you are about to declare the changes of your PHP,
you will need the php file. You will be
able to use default setting for server, create new text to name it with
php.ini, or change the specific setting through editing existing file of
php.ini. The php.ini is kind of file which is special for PHP as well as for
various flavors like suPHP.
0 komentar:
Posting Komentar