If I load a PHP page with Jquery .load(file.php), can the included file use the php variables that were defined on the page that called the load()?
The second argument (params) of the JQuery load function should be an object or a callback function, but could also be an empty string. Depending on that, load does send post or get requests.
I had the idea to switch automatically between get and post, (for example if cookie set),because get is more fast and cache able, and post is more save.
Its worse to write the load function including the content inside the callback function twice than to write something like that:
//get
var url="cache_dir/my_bag.html";
var params="";
if(document.cookie){
//post
url="post.php";
params="{my:bag}";
}
$(selector).load(url,params,function(){
...
});