• angularjs 发送ajax请求的问题


     在angularjs中使用 ajax 如果使用 jquery的 ajax发送请求会遇到结果返回了,但是页面的值却没有改变,如:

    $scope.queryNameMatch = function() {
    // $.ajax({
    // type : "POST",
    // timeout : 60000,
    // url : "/AutoNameMatchWeb/queryNameMatch.do",
    // dataType : 'json',
    // data : {
    // offerName : $("#offer_name_id").val()
    // },
    // success : function(result) {
    // $scope.reload(result);
    // }
    // });

    }

    因为系统就没有机会帮你调用$apply,界面也就没有机会刷新了,见:http://www.ngnice.com/posts/2c8208220edb94

    直接使用 angularjs提供的 http请求 即可

    $scope.queryNameMatch = function() {
    var postData = {text:'long blob of text'};
    var config = {params: {offerName: $("#i_offer_name").val()}};
    $http.post("http://localhost:8080/AutoNameMatchWeb/queryNameMatch.do"
    , postData, config ).success(function(result) {
    $scope.products = result.data.products;
    $scope.ruleName = result.data.ruleName;
    });
    };

    http://www.cnblogs.com/sytsyt/p/3297872.html

  • 相关阅读:
    Luogu P3275 糖果
    Python基础学习
    SharePoint 2013
    Office
    KnockoutJS
    SharePoint 2013
    Bootstrap
    SharePoint 2013
    CSS
    AngularJS
  • 原文地址:https://www.cnblogs.com/yidaxia/p/5383012.html
Copyright © 2020-2023  润新知