Friday, November 2, 2012

jQuery Get Text Response Example

The jQuery Get() ajax method supports HTML, XML, JSON and Text type responses sent by the server. In this post we shall see on how to process Text data returned from the server using the jQuery Get() method.

The syntax for receiving and processing Text response is as follows.

$.get("<Server URL>", successHandlerFunction(…));

The following example receives a Text format data from the server and displays the data in a DIV tag in the browser.

.aspx Page (Client Side)
<html xmlns="" >
<head runat="server">
    <title>jQuery Ajax Load</title>
    <script type="text/javascript" src="JavaScript/jquery-1.7.2.js"></script>
        $(document).ready(function() {
            // Get Text Response data from the Server
            $('#btnGetText').click(function(event) {
                $.get("AjaxData.txt", function(result) {
    <form id="frmAjax" runat="server">
    <table border="1">
            <tr valign="middle">
                        Text="Get Text" />
                <td align="center">
                    <br /><div id="divText"></div> 

.AjaxData.txt(Server Side)

This is a sample text placed in the server.

Search Flipkart Products:

No comments: