#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2016
    Posts
    109
    Rep Power
    3

    PHP MVC + Javascript fetch api issue


    Dear all,

    I am having problem passing form data to php mvc controller.

    I have controller = Assets.php
    method = process.php

    When I pass the url to fetch api, it throws 404 error. POST 301 Moved Permanently 404 Not found?

    here is the fetch
    Code:
    let url = 'http://localhost/app/views';
            fetch(url + '/assets/process', {
                method: "POST",
                body: params,
              })
    Far as I understood, my setup is 'assets' in the controller and 'method' is the process and 'param' is the params.
    Any idea what I am doing? Am I passing the url correctly to the fetch?

    Any suggestions would be greatly appreciated.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Specialist (4000 - 4499 posts)

    Join Date
    Jul 2003
    Posts
    4,468
    Rep Power
    653
    First please use the proper tags for your PHP code. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    Have you tried to paste the URL into a browser to see if you get the same error? It would appear that the problem is not with PHP but with the URL or the host.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2016
    Posts
    109
    Rep Power
    3
    Originally Posted by gw1500se
    First please use the proper tags for your PHP code. See the sticky at the top of this forum that says READ THIS BEFORE POSTING.

    Have you tried to paste the URL into a browser to see if you get the same error? It would appear that the problem is not with PHP but with the URL or the host.
    Thank you Mr gw1500se. My apology for not using the right kind of coding tags. After correcting the url, Now it is OK. Thanks a ton!
    Last edited by Brume007; February 23rd, 2018 at 02:01 PM.

IMN logo majestic logo threadwatch logo seochat tools logo