如何使用ionic v1将数据从angularjs发送到php?

时间:2017-04-11 00:25:56

标签: php angularjs ionic-framework

我是离子新手,我更喜欢使用离子v1 而不是 v2或更高。现在,我通过 CLI 下载了离子文件。我将它安装在驱动器d:上。我开始用空白模板制作一个示例项目。在编码时,我正在尝试将数据发送到我的php文件,它给我一个错误 http://localhost:8100/send.php 404 Not Found 。我尝试将 PHP文件置于 www / 文件夹之外且内部仍然存在错误。为什么?我已经在这个问题上搜索过很多东西,但我不明白。在这里;我的代码:

template<typename T>
T ReadMemory(uint64_t addr, size_t size){
    uint64_t some_address = addr;
    size_t string_size = size;
    uint64_t return_value;
    //store address contents into return_value using driver

    /* type is std::string */
    if constexpr (std::is_same<T,std::string>::value){
        return std::to_string(return_value);
    }
    /* type is uint64_t */
    if constexpr (std::is_same<T,uint64_t>::value){
        return return_value;
    }
}

我希望有人可以帮我解决我的问题。提前谢谢!

顺便说一下,这是我的文件夹结构:

$scope.send = function(){ $http.post('send.php',{ 'name': $scope.name }).then(function(response){ // msg }); }

PHP

Drive D > CORDOVA > sample_proj > myapp > www > index.html, send.php

1 个答案:

答案 0 :(得分:0)

经过调试并向@charlietfl询问了很多问题。我的问题解决了!谢谢他!正如他所说,&#34;将您的项目视为2 projects (first for your backend (php) and second to your frontend(ionic,etc.))&#34;。我只是将send.php文件放在htdocs folder in my xampp folder内,然后更改$http addres to : http://192.168.1.16/send.php。当然,为了让它完美运作,我把CORS in it看到我的帖子!它解决了这个问题!