douyi3767 2013-07-24 14:06 采纳率: 0%
浏览 28
已采纳

IBM worklight - 如何将请求参数发送到PHP文件?

This is my PHP code:

<?php

  mysql_connect("localhost","root","");
  mysql_select_db("sowrun_mobile");

 $ad_id = $_REQUEST['ad_id'];
  $sql=mysql_query("SELECT * FROM tbl_user_registration where reg_AD_ID='".$ad_id."'");

  $row='';
  while($row=mysql_fetch_assoc($sql)){


    $output[]=$row;
  }

  if($row == ''){
        $out['reg_AD_ID'] = '111111';
$output[]=$out;
}



  $jsonStr = json_encode($output);
  print($jsonStr);

  mysql_close();

?>

I am trying to send the parameter adid from the Worklight adapter with the following method:

function getFeeds() {

    WL.Logger.debug("inside method");

    var input = {

        method : 'get',

        returnedContentType : 'json',

        path : "ios/ClientadID.php"

    };

ClientadID.php contains the code which is written in the first code sample above.

I am trying to send the request from the adapter with the following parameters while invoking the procedure. In the parameter window I am sending ad_id=1 but an error is throwing:

Notice: Undefined index: ad_id in C:\wamp\www\ios\ClientadID.php on line 6

  • 写回答

1条回答 默认 最新

  • doutui2883 2013-07-24 15:30
    关注

    I'm not sure what you mean by "In the parameter window". When you invoke a worklight adapter from the worklight studio, the parameter window that comes up is so that you can pass parameters to your adapter function, not REST parameters.

    function getFeeds(myParameter) {
    
    // myParameter is what is passed from the parameter window
    
    WL.Logger.debug("inside method");
    
    var input = {
    
        method : 'get',
        returnedContentType : 'json',
        path : "ios/ClientadID.php"
    
    };
    

    If you're trying to pass a parameter for a GET or POST request, then you need to change your adapter "input" object like this:

    function getFeeds() {
    
    WL.Logger.debug("inside method");
    
    var input = {
    
        method : 'get',
        returnedContentType : 'json',
        path : "ios/ClientadID.php",
        parameters: {"ad_id": 1}
    
    };
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计