weixin_33738578 2015-11-27 17:26 采纳率: 0%
浏览 47

通过ajax显示PHP输出

I have a php script to check if a domain is available. It echos the result and there are 4 possible outputs;

  1. Is not available
  2. Is available
  3. Is registered, but can be transferred
  4. Is not available for transfer

I am trying to use ajax to send the domain and the tld to the script How do I echo the output of the script in my html? From what I understand is that is is possible to display a message if the php gives a result, but not to extract the result and display that under my html form.

So basically this is what happens at the moment:

form  ->  $domain $tld -> AJAX -> GET -> domaincheck.php -> $dom = $_GET['domain'];
 $tld = $_GET['tld']; -> $domain = $dom . $tld; -> TransIP API -> $result

$result gets set by this piece of php

try
    {
        $availability = Transip_DomainService::checkAvailability($domain);
        switch($availability)
        {
      //check availability
            case Transip_DomainService::AVAILABILITY_INYOURACCOUNT:
                $result = htmlspecialchars($domain)
                            . ' is not available.';
            break;

            case Transip_DomainService::AVAILABILITY_UNAVAILABLE:
                $result = htmlspecialchars($domain)
                            . ' is not available for transfer.';
            break;

            case Transip_DomainService::AVAILABILITY_FREE:
                $result = htmlspecialchars($domain)
                            . ' is available for registration.';
            break;


            case Transip_DomainService::AVAILABILITY_NOTFREE:
                $result = htmlspecialchars($domain)
                            . ' is registered. If you are the owner,
                                    you could transfer it.';
            break;
        }
    }
    catch(SoapFault $e)
    {
    //error
        $result = 'An error occurred: ' . htmlspecialchars($e->getMessage());
    }
}
else
{
    $domain = '';
    $result = '';
}

I am absolutely no programming genius, more an UI designer on the loose. So any help is appreciated :)

  • 写回答

1条回答 默认 最新

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 通过STM32F4实现智能清洁小车,要求用到三个以上传感器
      • ¥15 perl代码解释说明
      • ¥15 列举 五阶幻方 有多少种
      • ¥15 请教一下能人在VS中调用MATLAB绘制动态驻波
      • ¥15 VB.NET如何调用Microsoft Excel?(WPS存在时)
      • ¥15 KUKA机器人EtherNetIP通讯配置教程
      • ¥15 VB6.0如何模拟键盘组合按键
      • ¥15 python怎么替换这个word里边内容
      • ¥15 做谷歌浏览器插件的时候,怎么在background.js中优先执行其他.js文件里面函数呀?
      • ¥15 win 10家庭版非管理员账户如何获取管理权限