javascript - 将多个值从js页面传递到php页面

标签 javascript php angularjs

我想要从服务页面到 php 页面的多个值。我想将 'data'、'albimg'、'albvideo' 传递到 php 页面。现在我发现了如图所示的错误。 enter image description here

var deferred = $q.defer();
            data.pagename = "create_album";
            $http.post('js/data/album.php', {action:{"data":data,"albimg":albimg,"albvideo":albvideo}})
                    .success(function (data, status, headers, config)
                    {
                        console.log(status + ' - ' + action);
                        deferred.resolve(action);
                    })
                    .error(function (action, status, headers, config)
                    {
                        deferred.reject(action);
                        console.log('error');
                    });

            return deferred.promise;
php page:
$postdata = file_get_contents("php://input",true);
$request = json_decode($postdata);
$now = date('Y-m-d H:i:s');
echo $sql="INSERT INTO `$prefix.album` (CONTENT_VALUES,CreatedTime)VALUES('$postdata','$now')";

最佳答案

你可以通过使用 param 属性来做到这一点:像这样;

var data = {"data":data,"albimg":albimg,"albvideo":albvideo};

$http({ url: "js/data/album.php",    method: "POST",    params: data    })

关于javascript - 将多个值从js页面传递到php页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33863938/

相关文章:

php - 使用 DoctrineExtensions Translatable Symfony2 的数据库查询太多

php - Ajax /PHP : Call working correctly but not alerting result from PHP

javascript - Angular : Show div content depending on which option chosen from drop down menu (ng-show/ng-switch)

javascript - Linux Firefox 中的正文宽度错误

javascript - Alertify JS 中心对话框窗口

javascript - 如何安全地将 HTML 从模型绑定(bind)到 View

javascript - AngularJS 如何上传多个文件

javascript - 如何同时使用 jQuery 和 span 类?

php - 无法使用ajax在单击按钮时将表单数据插入数据库

javascript - 无法使用从 JSON 解析的 JavaScript 对象