SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: JQuery syntax

  1. #1
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JQuery syntax

    Please look at this JQuery tutorial

    JSP page
    ---------

    Code:
    <form method="post">
    	Enter City :
    <input id="cityName" name="cityName" size="30" type="text" />
    <input id="getWeatherReport" name="getWeatherReport" type="button" value="Get Weather" />
    </form>
    <div id="weatherReport" class="outputTextArea"></div>

    AJAX call
    ----------
    Code:
    <script type="text/javascript">
    	$(document).ready(function() {
    		$("#getWeatherReport").click(function(){
    			$cityName = document.getElementById("cityName").value;
    			$.post("WeatherServlet", {cityName:$cityName}, function(xml) {
    				$("#weatherReport").html( $("report", xml).text() );
    			});
    		});
    	});
    </script>
    what is "report" here . I don't see this in the JSP page .

    If I rename it say "myreport" . Will it still work ?

    my question is : Is "report" a keyword in JQuery ? or Can I write anything in that place ? Or It some dependency elsewhere ?

  2. #2
    SitePoint Guru whisher's Avatar
    Join Date
    May 2006
    Location
    Kakiland
    Posts
    732
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    report refer to the xml node

    Code XML:
    <?xml version="1.0"?>
    <mytest>
        <report>Report of the .....</report>
    </mytest>

    in this case
    Code JavaScript:
    $("report", xml).text()

    give you

    Report of the .....
    Bye

  3. #3
    SitePoint Addict
    Join Date
    Dec 2009
    Posts
    301
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by whisher View Post
    Hi,
    report refer to the xml node

    Code XML:
    <?xml version="1.0"?>
    <mytest>
        <report>Report of the .....</report>
    </mytest>

    in this case
    Code JavaScript:
    $("report", xml).text()

    give you



    Bye

    No . You are mistaken . I don't have any such XML.



    Here is the tutorial:

    http://veerasundar.com/blog/2008/12/...-using-jquery/


    I'd request you to answer doubts

    (i)what is "report" here . I don't see this in the JSP page .

    (2)If I rename it say "myreport" . Will it still work ?

    (3)Is "report" a keyword in JQuery ? or Can I write anything in that place ? Or It some dependency elsewhere ?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •