游.程 2015-04-24 18:06 采纳率: 0%
浏览 52

javascript ajax jQuery

I m validating variables from html inputs in ajax javascript .

What i m trying to do for sure is when client Click the Submit button which it variable is var sub another div from html file should appear but after completing to fill the required fields.

But when i tried doing it i get no response means the html div that should appear

HTML

            <span id="formst">User name:<input type="text" name="username" id="user" onBlur="checkU();"/>
            <div id="staut"></div>
            <br /><br />
            Phone Number:<input type="tel" name="number" id="tel" value="+255" />
            <div id="stau"></div>
            <br /><br />
            <h3>Your Description</h3>
            <textarea rows="6" cols="22" id="textarea" ></textarea><br /><br />
            <input type="submit" value="submit" onClick ="payment();" id="sub"/>
            <div id="st"></div>
            </span>
        </form>


<div id="payment2">

            <ul id="adjustPay">
                <li id="tigo" onClick="Tigo();">Tigo Pesa</li>
                <li id="voda">Vodacom Mpesa</li>
                <li id="air">AirTel Money</li>
            </ul>
        </div>
    </div>

and ajax javascript Jquery code

    var ajax = ajaxObj("POST", "function.php");
    info.innerHTML = "Please wait ...";
    ajax.onreadystatechange = function(){
        if(ajaxReturn(ajax) == true){

    if(ajax.responseText != "please wait"){
        info.innerHTML = ajax.responseText;
        sb.style.display = "block";

        }else if(ajax.responseText = "please wait"){

    $(document).ready(function(){

        $("#form").show(function(){
            $("#form").slideUp(3840);
            $("#payment2").show();

        });
    });
}


        }
    }

    ajax.send("u="+u+"&n="+n+"&t="+t);

}

Problem is on else if(ajax.responseTex = "please wait")

please if there is any way of doing this just show me

  • 写回答

1条回答 默认 最新

  • weixin_33717117 2015-04-24 18:19
    关注

    You need something like this - you need to change #sb and data to reflect the actual element and the data returned

    $(function(){
      $("#form").on("submit",function(e) { // when submitted
        e.preventDefault(); // cancel the submission
        $("#info").html("Please wait ...");
        $.post(function.php",$("#form").serialize(),function(data) {
         if (data != "please wait"){
           $("#info").html(data);
           $("#sb).show();
         else {
          $("#form").show(function(){
            $("#form").slideUp(3840);
            $("#payment2").show();
         });
      });
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog