weixin_33693070 2016-01-25 16:13 采纳率: 0%
浏览 41

$ http()不是函数

 Enter Where Condition: <input type="text" id="myText">
    <button onclick="myFunction()">Go</button>
    <script type="text/javascript">
    function myFunction($http) {
    var condition = document.getElementById("myText").value;
        $http({

            method: 'POST',
            url: "http://localhost:8080/peter/peter1/where",
            params: {"where":condition},
            headers: {'Content-Type': 'application/json'}

            });
        } 

    <script/>

When i tried to debug the above code i am getting an error saying that $http is not a function... In the above code i am getting error saying $http is not a function..please help me in resolving this problem...

  • 写回答

2条回答 默认 最新

  • weixin_33716154 2016-01-25 16:23
    关注
    Enter Where Condition: <input type="text" id="myText">
    <button onclick="myFunction($my_http)">Go</button>
    <script type="text/javascript">
    function myFunction($http) {
    var condition = document.getElementById("myText").value;
        $http({
            method: 'POST',
            url: "http://localhost:8080/peter/peter1/where",
            params: {"where":condition},
            headers: {'Content-Type': 'application/json'}
    
            });
        } 
    
    <script/>
    

    Notice that when you are calling the function myFunction() it should be called with a parameter containing an $http Object, like so:

    myFunction($http_example);
    

    AND NOT like so:

    myFunction();
    
    评论

报告相同问题?

悬赏问题

  • ¥15 2024-五一综合模拟赛
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题
  • ¥15 matlab中使用gurobi时报错
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭