Hi, I don't know how to ask this question that's why I'm going to simulate what I need, some developers make what I need by rendering javascript with php. A simple sample file would look like:
my_javascript_file.php
<?php include "my_class.php"; ?>
$(document).ready(function(){
$.ajax({
url: "<?php $my_obj->post_url(); ?>",
success: function(){
alert("Post successful")
}
});
};
which outputs following:
$(document).ready(function(){
$.ajax({
url: "/post_handler.php",
success: function(){
alert("Post successful")
}
});
};
my question comes there, is there any way to achieve that with pure js techniques?
Thanks, Sinan.
P.S. This is just a simple example of course I can hardcode post url here, or get url by location object etc with javascript I hope you get what I mean...
EDIT: Sorry for confusions by the terms I used, it is just getting some information from my application and writing to my javascript dynamically. I don't mean comet or data encode etc.
What I want to know is how to use server-side data on javascript files(if there is any way). Like what php method does on my example, it simply echoes a string which comes from my application. Is there a way to do that by a javascript library or a framework, like a template engine you assign vars and use it in that template system. Hope it's more clear now.