...

View Full Version : Jquery questions



mikehende
06-30-2011, 04:07 PM
I am not understanding something here with this:

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



<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 :


Let AJAX change this text

to:


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?

low tech
06-30-2011, 04:20 PM
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.

mikehende
06-30-2011, 04:26 PM
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?

devnull69
06-30-2011, 04:29 PM
Yes, you're right

low tech
06-30-2011, 04:33 PM
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
ps:)smile

mikehende
06-30-2011, 04:36 PM
Thanks, my next question relates to:


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?

devnull69
06-30-2011, 04:41 PM
$.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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum