# Not outputting a URL on your form

**URL:** <https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762>\
**Category:** Need Help\
**Created:** [January 15, 2018, 10:07pm UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762 "2018-01-15T22:07:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![zapatos](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@zapatos](https://discourse.cakephp.org/u/zapatos)\
**Post date:** [January 15, 2018, 10:07pm UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762/1 "2018-01-15T22:07:37Z")

</div>

I was reading the cakephp book, and I have a form that submits comments on an article.  
my form on my view page as of now is defined because I am stuck on 3 things. One when I create a form, the request an ajax request, but my controller doesn’t seem to catch it in an if. Two, my jquery ajax URL undoubtedly appends the url defined in my ajax script to the current page and goes no where, and lastly I am confounded by the possibility of this option for a form

> "Use ‘url’ =\> false if you don’t want to output a URL as the form action. "

.How do you submit an ajax form on cakephp?

---

<div class="post-metadata">

**Author:** ![Marcel](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/marcel/32/329_2.png) [@Marcel](https://discourse.cakephp.org/u/Marcel)\
**Post date:** [January 15, 2018, 10:26pm UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762/2 "2018-01-15T22:26:10Z")

</div>

Use in Form::create - “url” =\> “#”

in jquery

$("#yourFormId").on(‘submit’, function(e) {  
e.preventDefault(); // stop propagation of default event - which is form submit

… your ajax call here  
});

---

<div class="post-metadata">

**Author:** ![zapatos](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@zapatos](https://discourse.cakephp.org/u/zapatos)\
**Post date:** [January 16, 2018, 12:21am UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762/3 "2018-01-16T00:21:53Z")

</div>

> [@Marcel](#):
>
> .on(‘submit’, function(e) {
> 
> e.preventDefault();

This did prevent the default redirect, and called my ajax which in turn called my other controller method.  
Now my request data array is null?

---

<div class="post-metadata">

**Author:** ![Marcel](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/marcel/32/329_2.png) [@Marcel](https://discourse.cakephp.org/u/Marcel)\
**Post date:** [January 16, 2018, 9:56am UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762/4 "2018-01-16T09:56:22Z")

</div>

```
    $('#yoursForm').on('submit', function(e) {
        $.ajax({
            method: 'POST',
            url: 'yourUrl',
            data : $('#yoursForm').serialize()
        }).done(function( response ) {
              console.log(response);
        });
        e.preventDefault();
    });
```

---

<div class="post-metadata">

**Author:** ![zapatos](https://avatars.discourse-cdn.com/v4/letter/z/c5a1d2/32.png) [@zapatos](https://discourse.cakephp.org/u/zapatos)\
**Post date:** [January 17, 2018, 3:30am UTC](https://discourse.cakephp.org/t/not-outputting-a-url-on-your-form/3762/5 "2018-01-17T03:30:48Z")

</div>

Sir, I have to tell you , if you haven’t heard it today, but thank you you are awesome. After serializing my form data, I was able handle the request as anticipated.
