I want to save data using ajax. But AJAX callback function replace method not working ? why?
Fun issue here.  I pulled your code out and stuffed it into a test module and the ajax appeared to work once, eg, on first click of the ADD button, it replaced the &lt;div id="countvalue"&gt;foo&lt;/foo&gt; I had also stuffed into my page.tpl.php.  But then each successive click put up the throbber without any further apparent change.  Throwing a watchdog() into the callback showed it was indeed being called upon each click and then the voila moment:

return '&lt;div id="countvalue"&gt;count value is:' . $prod_1 . '&lt;/div&gt;';


is needed because it was replacing the original &lt;div id="countvalue"&gt; with just the count value is.... text, and then when clicked again, the DOM no longer contained a #countvalue for it to replace again :)