magento中的ajax无法正常工作

I am just beginner of Magento. I want to run an ajax in Magento from my .phtml file.I read a blog fot it but did not get any success.I just want to send a mail to my client when ever a form is submitted on Product Page.

This is my .phmtl file path and code.

 path - web/frontierFinal/app/design/frontend/default/frontier/template/catalog/product/view.phtml

and code

jQuery.ajax({
                        url: "<?php echo 

    $this->getUrl('groupedajax/ajax/index') ?>",
                            type: "POST",
                            data: "size=434",
                            success: function(data) {
                            $j('#thankyou').html(data);
                            }
                        });

I just followed the steps of the above mentioned blog as

1) First I create a module named groupedajax /web/frontierFinal/groupedajax

and then a new directory controllers and .php file /web/frontierFinal/groupedajax/controllers/AjaxController.php

then code of AjaxController.php

<?php
class Creare_Groupedajax_AjaxController extends Mage_Core_Controller_Front_Action {

    public function indexAction() {
        echo "sasd";
    }
}
?>

then a xml file named config as /httpdocs/web/frontierFinal/groupedajax/etc/config.xml

and code of this file is

<?xml version="1.0"?>
<config>
  <modules>
    <Creare_Groupedajax>
      <version>0.1.0</version>
    </Creare_Groupedajax>
  </modules>
  <frontend>
    <routers>
      <groupedajax>
        <use>standard</use>
        <args>
          <module>Creare_Groupedajax</module>
          <frontName>groupedajax</frontName>
        </args>
      </groupedajax>
    </routers>
    <layout>
      <updates>
        <groupedajax>
          <file>groupedajax.xml</file>
        </groupedajax>
      </updates>
    </layout>
  </frontend>
</config>

then a mapping xml file as /httpdocs/web/frontierFinal/app/design/frontend/default/frontier/layout/groupedajax.xml

<?xml version="1.0"?>
<layout version="1.0">
  <groupedajax_ajax_index>
    <block type="groupedajax/groupedajax" name="root" output="toHtml" template="template/catalog/product/view.phtml" />
  </groupedajax_ajax_index>
</layout>

I know I dont have clear understanding of directories thats why this problem is coming up.But I need your help guys.

When I run ajax it shows 404 not found.

Please help thanks

Your directories are completely wrong. So Magento does not use any of your code.

Please look into tutorials like these for more info: http://coding.smashingmagazine.com/2012/03/01/basics-creating-magento-module/ or http://www.excellencemagentoblog.com/magento-part4-series-helloworld

Your base dir is web/frontierFinal/. Then everything should reside in it, mostly in app. That's where all files are located in those tutorials.

In your .phtml file use

<script type="text/javascript">
  jQuery("#form_post").submit(function() {
    var posdata = jQuery("#form_post").serializeArray();
    var url = "<?php echo Mage::getUrl('test/index/save') ?>";
    jQuery.ajax({
      type: "POST",
      url: url,
      datatype: "text",
      data: posdata,
      success: function(data)
      {
        $$(".result").invoke("update",data.replace(/\"/g, ""));
      }
    });
    return false;
  });
</script>

And in controller add

public function saveAction()
{
  $result=Mage::app()->getRequest()->getParam('telephone');;
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
}