简体   繁体   中英

Cannot POST /url with AngularJS & PHP Mailform

I'm trying to send email message through an AngularJS application with PHPMailer. Everytime I submit the form I am redirected to a blank page on url http://192.168.1.38:3000/#/contact saying

CANNOT POST /

My contact form is in another html file pages/contact.html and the routing is

        .when('/contact', {
          templateUrl : 'pages/contact.html',
          controller  : 'ContactController'
        });

My contact form begins with

 <form ng-submit="submit(contactform)" name="contactform" method="post" action="" class="form-horizontal" role="form">

I'm wondering if I can not leave action="" blank on the form. But I've also tried putting /#contact and /#/contact but the same error always shows up.

When I am on the contact page the url is http://192.168.1.38:3000/#/contact

When submitting the form, the console spits out:

POST http://192.168.1.38:3000/ 404 (Not Found)

and network tab says:

Remote Address:192.168.1.38:3000
Request URL:http://192.168.1.38:3000/
Request Method:POST
Status Code:404 Not Found
----------------------------------------------
Content-Type:application/x-www-form-urlencoded

I do however receive the email that I send from the email form from the web application so it's only that I can get rid of this error. I've tried uploading my whole application onto a server but it still gives me the same error.

Remove action="" and the page will not attempt to redirect. If you do want to show a success page, place it in the action="" .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM