javascript - Angularjs http post won't send data if all form fields are populated -
i using anglarjs. have select tag on form. on change call function sends http post , retrieves data. works when before everthing select value select box,then gets data. if populate 1 other field , change dropdown list value,it won't send http post. don't understand problem.
here part of form:
. . . <div class="form-group" > <label>num<span class="error">*</span></label><span data-ng-show="user.userform1.num.$touched && user.userform1.num.$invalid " class="error">required</span> <input type="text" class="form-control" name="num" data-ng-model="user.num" required data-ng-pattern="/^[0-9]{13,13}$/" data-ng-value="num"/> </div> <div class="form-group" > <label class="control-label">city<span class="error">*</span></label><span data-ng-show="user.userform1.selectedcity.$touched && user.userform1.selectedcity.$invalid" class="error">required</span> <select ng-change="sendselection()" data-ng-model="user.selectedcity" class="form-control" name="selectedcity" required data-ng-value="user.selectedcity" > <option value="">chose city</option> <option >city1</option> <option >city2</option> <option >city3</option> <option >city4</option> </select> </div> . . .
here mu function inside controller:
$scope.sendselection = function() { $http({ method: 'post', url: 'add.php', withcredentials: true, data: "selection="+$scope.user.selectedcity, datatype: "json", headers: {'content-type': 'application/x-www-form-urlencoded'} }) .success(function(data) { alert(data); }) .error(function(err) { alert(data); }); }
it works on localhost when put on real server has problem mentioned above.
Comments
Post a Comment