gpt4 book ai didi

javascript - 浏览器因 Angular $http 函数而挂起

转载 作者:行者123 更新时间:2023-11-30 00:09:15 24 4
gpt4 key购买 nike

这是我的代码。

<html>
<title>Doctor List</title>

<head>
<link rel="stylesheet" type="text/css" href="css/DoctorStay.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<script type="text/javascript" src="angular.min.js"></script>
<script type="text/javascript" src="js/jquery-2.2.1.min.js"></script>
<script type="text/javascript">
var d = new Date();
var weekday = new Array(7);
weekday[0]= "Sunday";
weekday[1] = "Monday";
weekday[2] = "Tuesday";
weekday[3] = "Wednesday";
weekday[4] = "Thursday";
weekday[5] = "Friday";
weekday[6] = "Saturday";

var app=angular.module('DListApp',[]);
app.controller('DListCtrl',function($scope,$http){

$http({
method : "POST",
url : "http://localhost:81/DoctorStayServiceAngular/model/getDoctorList.php",
params:{"city":"Surat","special":"Dentist","offset":"0","gender":"Any","fees":"Any","page":"10","state":"Gujarat","country":"IN"}
}).then(function mySucces(response) {
$scope.DoctorDeatil = response.data;
}, function myError(response) {
$scope.DoctorDeatil = response.statusText;
});

$scope.booking= function(docid,addid){
//return addid;
$http({
method: 'POST',
url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
//params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
params:{"doctorid":docid}
}).then(function mySucces(response) {
return response.data;
});
};

});
</script>
</head>
<body>
<div class="ListMargin">
<input type='hidden' id='current_page' />
<input type='hidden' id='show_per_page' />
<div class="row">
<div class="row" id="header"></div>
<div class="col-sm-3 AreaScroll" id="area"></div>
<div class="col-sm-8 pagination-sm" ng-app="DListApp" ng-controller="DListCtrl">
<div id="list" ng-repeat="x in DoctorDeatil">
<div class="row DocList">
<div class="container">
<div id="DocImg" class="col-sm-2">

</div>
<div id="DocDetail" class="col-sm-4">
<div class="row">
<a href="{{ x.profile_url}}">Dr. {{ x.fname}} {{ x.lname}}.</a>
</div>
<div class="row">
{{ x.lname}}
</div>
<div class="row">
{{ x.dredu}}
</div>
<div class="row">
{{ x.drspec}}
</div>
<div class="row">
<a href="{{ x.clinic_url}}"> {{ x.clinicname}}.</a>
</div>
</div>
<div id="DocAppoinment" class="col-sm-3">
{{booking(x.profileid,x.addressid)}}
</div>
</div>
</div>
</div>
</div>

</div>
</div>
<!-- <div >


</div> -->

</body>

$scope.booking= function(docid,addid){}当我使用 $http 时起作用功能我的浏览器挂了这么多。这是我的 PHP 代码。

<?php
header("Access-Control-Allow-Origin: *");
header("Content-Type: application/json; charset=UTF-8");
echo json_encode($_REQUEST['doctorid']);
?>

我没有做任何新的事情然后我也面临着问题。

This is my console output

编辑

我已经像这样更改了预订功能。

$scope.booking= function(docid,addid){
i++;
console.log(i);
//console.log(addid);
return addid;
/* $http({
method: 'POST',
url: "http://localhost:81/DoctorStayServiceAngular/model/getDoctorBookingDetail.php",
//params:{"doctorid":docid,"addressid":addid,"day":weekday[d.getDay()]}
params:{"doctorid":docid}
}).then(function mySucces(response) {
return response.data;
});*/
};

在控制台中我得到了这个 OP。

Output

为什么我的预订功能执行了 2 次?控制台日志中应该只有 1 到 10。

最佳答案

你能解释一下为什么你在 ng-repeat 中这样做吗:

<div id="DocAppoinment" class="col-sm-3">
{{booking(x.profileid,x.addressid)}}
</div>

关于javascript - 浏览器因 Angular $http 函数而挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179148/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com