Ajax form as block and php file

Permalink
Hello I created a block ajax form
my view.php is
<form id="form_test" action="form.php" enctype="multipart/form-data" method="post"> ..... </form>

My ajax
function submitForm(formData) {
   $.ajax({   
      type: 'POST',
      url: 'form.php',      
      ..... etc.....

The problem is:
http://mywebsite.com/index.php/page(whatever)/test.php... (Not Found)
because is in the block what to do???

sergio11ofpp
 
JohntheFish replied on at Permalink Reply
JohntheFish
The target for ajax calls within c5 should usually be set up as a tool or an action in the associated page controller. c5 includes helpers that generate the correct action paths.

The reason is that to answer an ajax call c5 does not want to render a full page, so needs to provide an entrance to the ajax responder withou rendering a page.

You may find the links in this post from yesterday helpful.
http://www.concrete5.org/community/forums/customizing_c5/ajax-into-...
sergio11ofpp replied on at Permalink Reply
sergio11ofpp
I made it a little bit easier for me. I moved the php file in another folder wrote an if statement
if(form1){
if (mail($mail, "email subject", $message)) {
echo '1';
} else {
echo '0';
}
}

if(form2)
if (mail($mail2, "email subject", $message)) {
echo '1';
} else {
echo '0';
}

So I use one form.php for all 5 different Ajax forms