简体   繁体   中英

AngularJS application Add and Update does not work in IE

I came across this scenario that you do update and Add in IE but see results in Chrome :D

// Take cartegory object and id from the parent
    $scope.addNewCategory = function (category, parentId) {
        $scope.resetError();
        category.parentId = parentId.id;

        $http.post('/guardian/springmvc/categories/addCategoryValue', category).success(function () {
            $scope.retriveCategoryValues(parentId);
            $scope.category.parentId = '';
            $scope.category.name = '';
            $scope.category.description = '';

        }).
            error(function (data, status, headers, config) {
                // called asynchronously if an error occurs
                // or server returns response with an error status.
                $scope.setError('Could not add new category');
                console.log(data);
            });
    };

    // Take cartegory value object and id from the parentId
    $scope.editCategoryValue = function (categoryValue, parentId) {
        $scope.resetError();
        categoryValue.id = categoryValue.id;
        categoryValue.parentId = parentId.id;
        $http.put('/guardian/springmvc/categories/updateCategoryValue', categoryValue).success(function () {
            $scope.retriveCategoryValues(parentId);
            $scope.categoryValue.parentId = '';
            $scope.categoryValue.id = '';
            $scope.categoryValue.name = '';
            $scope.categoryValue.description = '';
            $scope.editMode = false;
        }).
            error(function (data, status, headers, config) {
                // called asynchronously if an error occurs
                // or server returns response with an error status.
                $scope.setError('Could not update category');
                console.log(data);
            });
    };

Rest Controller code is mentioned as shown below.

IN chrome, Insert and Update has been working.

/**
 * Creates a new category.
 * @param created The information of the category to create.
 * @return The created category.
 */
@RequestMapping(method = RequestMethod.POST, value = "/addCategoryValue", produces = "application/json")
public
@ResponseBody
OrgCategoryDTO addNewCategory(@RequestBody OrgCategoryDTO categoryToCreate) {
    try {
        if(LOGGER.isInfoEnabled()) {
            LOGGER.info("CategoryController: calling categoryService's create");
        }
        if(categoryToCreate != null)
        return categoryService.create(categoryToCreate);
    } catch (Exception e) {
        LOGGER.debug("Exception  " + e);
    }
    return new OrgCategoryDTO();
}

/**
 * Updates the information of a category.
 * @param updated The information of the category to update.
 * @return void.
 */

@RequestMapping(method = RequestMethod.PUT, value = "/updateCategoryValue", produces = "application/json")
public
@ResponseBody
void updateCategory(@RequestBody OrgCategoryDTO categoryToUpdate) {
    if(LOGGER.isInfoEnabled()) {
        LOGGER.info("CategoryController: calling categoryService's update");
    }
    try {
        if(categoryToUpdate != null)
        categoryService.update(categoryToUpdate);
    } catch (Exception e) {
        LOGGER.debug("Exception  " + e);
    }
}

Server Logs for Update action

SUCCESSFULLY LOADED validation.properties via the CLASSPATH from '/ (root)' using current thread context class loader!
Hibernate: select orgcategor0_.CATEGORY_ID as CATEGORY1_0_0_, orgcategor0_.CMS_TIMESTAMP as CMS2_0_0_, orgcategor0_.DESCRIPTION as DESCRIPT3_0_0_, orgcategor0_.ENABLED as ENABLED4_0_0_, orgcategor0_.ROW_TIMESTAMP as ROW5_0_0_, orgcategor0_.CATEGORY_LEVEL as CATEGORY6_0_0_, orgcategor0_.NAME as NAME7_0_0_, orgcategor0_.CATEGORY_TYPE as CATEGORY8_0_0_ from ORG_CATEGORY orgcategor0_ where orgcategor0_.CATEGORY_ID=?
Hibernate: update ORG_CATEGORY set CMS_TIMESTAMP=?, DESCRIPTION=?, ENABLED=?, ROW_TIMESTAMP=?, CATEGORY_LEVEL=?, NAME=?, CATEGORY_TYPE=? where CATEGORY_ID=?

Server logs for Insert Action

Hibernate: select orgcategor0_.CATEGORY_ID as CATEGORY1_0_0_, orgcategor0_.CMS_TIMESTAMP as CMS2_0_0_, orgcategor0_.DESCRIPTION as DESCRIPT3_0_0_, orgcategor0_.ENABLED as ENABLED4_0_0_, orgcategor0_.ROW_TIMESTAMP as ROW5_0_0_, orgcategor0_.CATEGORY_LEVEL as CATEGORY6_0_0_, orgcategor0_.NAME as NAME7_0_0_, orgcategor0_.CATEGORY_TYPE as CATEGORY8_0_0_ from ORG_CATEGORY orgcategor0_ where orgcategor0_.CATEGORY_ID=?
Hibernate: select childcateg0_.FK_ORG_CATEGORY_ID as FK5_0_2_, childcateg0_.CATEGORY_IMPCATEGORY_ID as CATEGORY1_2_2_, childcateg0_.CATEGORY_IMPCATEGORY_ID as CATEGORY1_2_1_, childcateg0_.FK_ORG_IMP_CAT_ID as FK4_2_1_, childcateg0_.CMS_TIMESTAMP as CMS2_2_1_, childcateg0_.ROW_TIMESTAMP as ROW3_2_1_, childcateg0_.FK_ORG_CATEGORY_ID as FK5_2_1_, orgcategor1_.CATEGORY_ID as CATEGORY1_0_0_, orgcategor1_.CMS_TIMESTAMP as CMS2_0_0_, orgcategor1_.DESCRIPTION as DESCRIPT3_0_0_, orgcategor1_.ENABLED as ENABLED4_0_0_, orgcategor1_.ROW_TIMESTAMP as ROW5_0_0_, orgcategor1_.CATEGORY_LEVEL as CATEGORY6_0_0_, orgcategor1_.NAME as NAME7_0_0_, orgcategor1_.CATEGORY_TYPE as CATEGORY8_0_0_ from ORG_CATEGORY_MAP childcateg0_ left outer join ORG_CATEGORY orgcategor1_ on childcateg0_.FK_ORG_IMP_CAT_ID=orgcategor1_.CATEGORY_ID where childcateg0_.FK_ORG_CATEGORY_ID=?
Hibernate: insert into ORG_CATEGORY (CMS_TIMESTAMP, DESCRIPTION, ENABLED, ROW_TIMESTAMP, CATEGORY_LEVEL, NAME, CATEGORY_TYPE, CATEGORY_ID) values (?, ?, ?, ?, ?, ?, ?, ?)
Hibernate: insert into ORG_CATEGORY_MAP (FK_ORG_IMP_CAT_ID, CMS_TIMESTAMP, ROW_TIMESTAMP, FK_ORG_CATEGORY_ID, CATEGORY_IMPCATEGORY_ID) values (?, ?, ?, ?, ?)

遵循来自https://docs.angularjs.org/guide/ie的步骤遵循上述url中提到的每个步骤,并且也可以使其在IE中正常工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM