php - why ajax call behaves strange in similar situation? -


i'm using ajax call in login.php twice , call ajax.php 2 different parameter:

login.php

$(function()  { $("#slctsys").focusin(function()                    { $.get("ajax.php"                           ,{sysuser:$("#sysuser").val(), sysupw:$("#syspswd").val()}                           ,function(data1) {$("#slctsys").html(data1); });                     })                  .change(function()                     { $.get("ajax.php"                            ,{sysid:$("#slctsys").val()}                            ,function(data2) {$("#divurl").text(data2);});                     });   }); 

ajax.php

<?php include_once('function.php');  if (isset($_get['sysuser']))  { $c=sysselectdb('sysdb');    $sysinfo=$c->prepare('select sysname sysinfo                    sysuun = "'.$_get['sysuser'].'"                      , sysupw = "'.$_get['sysupw'].'"');     $sysinfo->execute();    $ijk='<option value=-1>select ...</option>';    if ($sysinfo->rowcount()>0)     { while ($data = $sysinfo->fetch(pdo::fetch_assoc))        { $ijk.='<option value='.$data['sysid'].'>'.$data['sysname'].'</option>'; }}    else { $ijk='<option value=-1>no access !!!</option>'; }    $sysinfo->closecursor();    $c=null;    echo $ijk; }  if (isset($_get['sysid']))  { $c=sysselectdb('sysdb');    $s='select * sysacss sysid='.$_get['sysid'];    $sysinfo=$c->prepare($s);    $sysinfo->execute();    if ($sysinfo->rowcount()==1)     { $data=$sysinfo->fetch(pdo::fetch_assoc); $retval=implode("#;#",$data); }    $sysinfo->closecursor();    $c=null;    echo '$retvalsalam'; } 

i include function.php inside of ajax.php see:

function.php

<!doctype html> <meta content="text/html; charset=utf-8" http-equiv=content-type> <link    href="/sysdb/resource/sysstyle.css" rel="stylesheet" /> <script  src ="/sysdb/resource/jquery-2.1.1.min.js"></script>  <script> function timer()  { var ct=new date();    var ch=ct.gethours();    var cm=ct.getminutes();    var cs=ct.getseconds();    return (ch<10?"0":"")+ch+(cm<10?":0":":")+cm+(cs<10?":0":":")+cs; } 

...

on first ajax call retrived data ok. in second, function.php pre append returned value. why?

i find solution based on issue @mstannu. u r right. use ob_start() before , ob_end_clean() after include function. , problem solved. think second call pre append include file output, both of ajax calls have same behavior. tnx.


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -