Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts

    Jquery questions

    I am not understanding something here with this:

    http://www.w3schools.com/jquery/jquery_ajax.asp

    Code:
    <html>
    <head>
    <script type="text/javascript" src="jquery.js"></script>
    <script type="text/javascript">
    $(document).ready(function(){
      $("button").click(function(){
        $("div").load('test1.txt');
      });
    });
    </script>
    </head>
    <body>
    
    <div><h2>Let AJAX change this text</h2></div>
    <button>Change Content</button>
    
    </body>
    </html>
    When you click on the button, AJAX changes the text :

    Code:
    Let AJAX change this text
    to:

    Code:
    AJAX is not a programming language.
    
    It is just a technique for creating better and more interactive web applications.
    My question is, where is this text above located since it's not in the code? Also, if I wish to change the text mentioned, how can I do so please?

  • #2
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    884
    Thanks
    173
    Thanked 101 Times in 101 Posts
    Hi

    I believe it tells you on the page you posted


    With jQuery AJAX, you can request TXT, HTML, XML or JSON data from a remote server using both HTTP Get and HTTP Post.

    And you can load remote data directly into selected HTML elements of your web page!


    The jQuery load() method is a simple (but very powerful) AJAX function.

    So test1.txt is a file on the server and jquery uses load (an AJAX function) to grab it and put it in the div.


    LT
    ps I don't know jquery so this is just my opinion based on the info given.

  • Users who have thanked low tech for this post:

    mikehende (06-30-2011)

  • #3
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts
    Thanks, very well explained. So does this mean that I would need to have access to the server to either add a file of my own to reflect the text I need and then call it via AJAX load function giving the name of the specific file?

  • #4
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Yes, you're right

  • #5
    Regular Coder low tech's Avatar
    Join Date
    Dec 2009
    Posts
    884
    Thanks
    173
    Thanked 101 Times in 101 Posts
    Hi

    does this mean that I would need to have access to the server to [either] add a file of my own to reflect the text I need and then call it via AJAX load function giving the name of the specific file?

    Yep, I would say that's a reasonable conclusion.


    Bearing in mind that I don't know jquery or AJAX.

    LT
    pssmile

  • #6
    Regular Coder
    Join Date
    Nov 2010
    Posts
    295
    Thanks
    105
    Thanked 0 Times in 0 Posts
    Thanks, my next question relates to:

    Code:
    Low Level AJAX
    
    $.ajax(options) is the syntax of the low level AJAX function.
    
    $.ajax offers more functionality than higher level functions like load, get, and post, but it is also more difficult to use.
    
    The option parameter takes name|value pairs defining url data, passwords, data types, filters, character sets, timeout and error functions.
    I have no idea what they are talking about here? Can anyone give an example please?

  • #7
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    $.ajax is the more general implementation of Ajax for jQuery (general means "low level" in this context).

    Everything you can do with $.post, $.get .load etc can also be done with $.ajax but not vice versa

  • Users who have thanked devnull69 for this post:

    mikehende (06-30-2011)


  •  

    Posting Permissions

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