inject javascript functions on server asp.net/php
<p>I created a small javascript library that makes making ajax calls using POST and JSON much easier for webmethods. Right now I still have to make a function stub in javascript for each matching webmethod. What I would love to do in asp.net mainly, and if possible in php too, would be that before sending the page to the client, the server examines the exposed webmethods and automatically injects the stubs in the javascript on the page before it sends the page to the client.</p>

<p>In ASP.NET I'm sure there is some way to use reflection to find these and then some way to inject javascript to the page before sending. I'm sure I could figure out the reflection part, but not sure how to inject javascript to the page from the server. <strong>Does anyone know how to inject javascript to a page on the server side?</strong></p>

<p>Also, does php have a way to sort of reflect on it's functions to also do this? Would be cool if this solution could work on multiple platforms.</p>
