Reputation: 520
I use a function on my website, count($opt, $amount), a PHP function and it returns integer value, Ex. 20.
I've various products, I use this function to count available stock. Ex. A handicraft (sku-101), price $51. count('sku-101', 51) will return the actual available stock for the item.
I do use this function many times in my website. I want to keep a button for user which can retrieve output without refreshing the whole page.
I searched and got too many results but each of those were "to post data in a specific URL and retrieve response". But in my case I need to run count($opt, $amount) on a button click, without posting data and get response.
jQuery/Ajax which can help me to get that? I need your guideline.
Upvotes: 2
Views: 72
Reputation: 2383
Your "count" function seems to be a server side function (if I understand correctly your question). So this mean that the work is done by the server. PHP and C# are server side languages (and many other). So you don't have the choice to call an URL if you want to call this function! Still, there are different ways to call this whithout realoading the page : Ajax, iFrame, UpdatePanel, etc.
If you absolutly don't want to call an URL, you need to use a client side language, like Javascript.
Upvotes: 1