首页 \ 问答 \ 在Ajax / jQuery中实现“成功”(Function 'success' in Ajax/jQuery)

在Ajax / jQuery中实现“成功”(Function 'success' in Ajax/jQuery)

我在使用Ajax调用的成功函数显示值时遇到问题。 我的代码如下。

$.ajax({
    type: "POST",
    url: "http://localhost/practical 8/checkuser.php",
    data: form_data,
    success: function(response)
    {
        if(response == 'success'){
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }else if(response == 'fail'){
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }
    }
});

我的checkuser.php基本上回声“成功”或“失败”。

我的成功函数中的ifelse if语句不起作用。 但是做

$.ajax({
    type: "POST",
    url: "http://localhost/practical 8/checkuser.php",
    data: form_data,
    success: function(response)
    {
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }
    }
});

工作得很好。 我究竟做错了什么?


I'm having problems displaying a value from the success function of my Ajax call. My code is as follows.

$.ajax({
    type: "POST",
    url: "http://localhost/practical 8/checkuser.php",
    data: form_data,
    success: function(response)
    {
        if(response == 'success'){
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }else if(response == 'fail'){
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }
    }
});

My checkuser.php basically echos "succcess" or "fail".

My if and else if statements in my success function are not working. But doing

$.ajax({
    type: "POST",
    url: "http://localhost/practical 8/checkuser.php",
    data: form_data,
    success: function(response)
    {
            $("#errorUsername").html("<label class='error'>"+response+"</label>");
        }
    }
});

works perfectly. What am I doing wrong?


原文:https://stackoverflow.com/questions/6020401
更新时间:2023-04-19 07:04

最满意答案

只需使用内置函数round() 。 你可以使用像round($float,$precision)这样的函数来指定精度(你想要多少个小数点round($float,$precision)

http://php.net/manual/en/function.round.php


Just use the built in function round(). You can specify precision(how many decimal points you want) by using the function like so round($float,$precision).

http://php.net/manual/en/function.round.php

相关问答

更多
  • 你可能必须为此创建一个自定义控件,但是你真的需要一个圆形按钮吗? 每个平台都有其UI约定,iPhone也不例外。 用户期望按钮是圆角矩形。 更新回应评论: 如果我明白这一点,你不会寻找一个圆形的按钮,而是一个可点击的(可触摸的)图像。 您可以使用UIImageView及其touchesBegan方法。 更新2: 等一下。 我们在谈论什么样的单选按钮? 出于某种原因,我以为你想模仿一个真正的收音机。 如果您正在讨论单选按钮组,请使用UISegmentedControl或UIPicker 。 You'd pro ...
  • 你可以使用C ++ 11的std::round() 。 如果您仍然坚持使用较老的标准,可以使用std::floor() ,它总是舍入到较低的数字,而std::ceil()始终舍入到较高的数字。 要获得正常的舍入行为,您的确使用floor(i + 0.5) 。 这样会给你带负数的问题,这个问题的解决方法是使用ceil()作为负数: double round(double number) { return number < 0.0 ? ceil(number - 0.5) : floor(number ...
  • 如果你的内线是A和B而你想要的是(A / B)只是计算(A+B-1)/B If your ints are A and B and you want to have ceil(A/B) just calculate (A+B-1)/B.
  • 在drawable文件夹中创建一个名为roundedbutton.xml的xml文件
    你应该使用ceil def my_round a (a / 100.0).ceil * 100 end my_round 4233.000001 # => 4300 my_round 52825 # => 52900 my_round 627444 # => 627500 my_round 111999 # => 112000 You should use ceil def my_round a (a / 100.0).ceil * 100 end my_round 4233.000001 # ...
  • 对于如何舍入没有完全正确的答案。 差异与如何处理恰好落在中点的值有关。 Application.Round将始终在该实例中向上舍入。 例如0.5将舍入到1.0。 VBA.Round将中断与最接近的偶数相关联 1.5-->2 2.5-->2 3.5-->4 等等。 这是减少总是四舍五入的固有偏差的几种方法之一。 此外,如果有兴趣, 本维基百科文章中有关Rounding的相当广泛的讨论 There is no entirely correct answer for how to round. T ...
  • 只需使用内置函数round() 。 你可以使用像round($float,$precision)这样的函数来指定精度(你想要多少个小数点round($float,$precision) 。 http://php.net/manual/en/function.round.php Just use the built in function round(). You can specify precision(how many decimal points you want) by using the func ...
  • 既然你提到numpy np.around(df.A.values/5, decimals=0)*5 Out[31]: array([505., 510., 610., 615.]) Since you mention numpy np.around(df.A.values/5, decimals=0)*5 Out[31]: array([505., 510., 610., 615.])
  • 所以我一直在尝试使用Colonel Thirty Two提示,使用Binding函数 ,但sqlite-net不提供这样的功能。 我转向System.Data.SQLite.dll,以帮助其他人: 首先在c#中创建自定义函数 [SQLiteFunction(Name = "RoundAccounting", Arguments = 2, FuncType = FunctionType.Scalar)] public class RoundAccounting : SQLiteFunction { p ...
  • 舍入是一个根本上不可区分的功能,所以你在那里运气不好。 这种情况的正常过程是找到一种方法来使用概率,比如通过使用它们来计算预期值,或者通过获取输出的最大概率并选择那个作为网络的预测。 如果您没有使用输出来计算损失函数,那么您可以继续将其应用于结果,如果它是可微分的则无关紧要。 现在,如果你想要一个信息性的损失函数来训练网络,也许你应该考虑保持输出的概率格式实际上是否对你有利(它可能会使你的训练过程更顺畅) - 那样你训练后,可以将概率转换为网络外的实际估计值。 Rounding is a fundament ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)