douqujin2767 2015-04-06 00:47
浏览 41
已采纳

组合不同的Javascript框架有缺点吗?

I intend on using Angular for some front end stuff, but using it for Ajax with PHP files the code becomes more verbose compared to jquery.

for example

app.controller('sign_up', function ($scope, $http) {
    /*
    * This method will be called on click event of button.
    * Here we will read the email and password value and call our PHP file.
    */
    $scope.check_credentials = function () {

        document.getElementById("message").textContent = "";

        var request = $http({
            method: "post",
            url: window.location.href + "login.php",
            data: {
                email: $scope.email,
                pass: $scope.password
            },
            headers: { 'Content-Type': 'application/x-www-form-urlencoded' }
        });
        /* Check whether the HTTP Request is successful or not. */
        request.success(function (data) {
            document.getElementById("message").textContent = "You have login successfully with email "+data;
        });
    }
});

And then you need to decode json etc. So if I use jquery for AJAX and angular for everything else, there won't be any conflicts or anything?

Thanks

  • 写回答

2条回答 默认 最新

  • dongzhi7763 2015-04-06 00:57
    关注

    Im a huge fan of Angular, JQuery, Bootstrap, AngularUI and jinqJs

    They all have there purposes. Angular has become very popular for the UI and is even better using AngularUI. Mixed with Bootstrap I find I code less and my sites look better. JQuery so I can query the DOM and I use jinqJs to query javaScript data like I would using SQL like expressions. I havent had any issue using all frameworks together. The service in this case is PHP but of course it could be a .Net Web API too. As long as the data format is JSON for example using a predefined structure then what you use for front end and back end are non impacting to each other.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 关于多单片机模块化的一些问题
  • ¥30 seata使用出现报错,其他服务找不到seata
  • ¥35 引用csv数据文件(4列1800行),通过高斯-赛德尔法拟合曲线,在选取(每五十点取1点)数据,求该数据点的曲率中心。
  • ¥20 程序只发送0X01,串口助手显示不正确,配置看了没有问题115200-8-1-no,如何解决?
  • ¥15 Google speech command 数据集获取
  • ¥15 vue3+element-plus页面崩溃
  • ¥15 像这种代码要怎么跑起来?
  • ¥15 安卓C读取/dev/fastpipe屏幕像素数据
  • ¥15 pyqt5tools安装失败
  • ¥15 mmdetection