View Single Post
Old 08-31-2009, 11:26 PM   #1 (permalink)
9three
The Contributor
 
Join Date: Oct 2008
Posts: 75
Thanks: 4
9three is on a distinguished road
Default AJAX call externally

Hey,

I've seen some sites that do the following:

<a href="example.php" onclick="ajax_functionname(parameter)">Example</a>

Which then that function calls an external file and does what it's suppose to do.

I'm currently using jQuery and every example is done inline. Which means people can view the source, how it functions, what page gets requested, and most importantly it means I have to go to every page with that same function and edit it page by page.

For example, in one of my pages I do this:

Code:
$.ajax({
  url: "test.html",
  cache: false,
  success: function(html){
    $("#results").append(html);
  }
});
I know that I could do $('.ajax').onclick(function () {...}) but it still shows what's happening.

How can I accomplish using this style instead?
9three is offline  
Reply With Quote