Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Javascript文件中的非法字符导致表单无法与Jquery一起使用_Php_Javascript_Jquery_Html_Illegal Characters - Fatal编程技术网

Php Javascript文件中的非法字符导致表单无法与Jquery一起使用

Php Javascript文件中的非法字符导致表单无法与Jquery一起使用,php,javascript,jquery,html,illegal-characters,Php,Javascript,Jquery,Html,Illegal Characters,有人能看一下这些吗,这对我来说只是一个html表单,一个处理它的php文件和一个javascript文件,from浏览器中的错误显示了一些东西,比如JScript文件中的U+12AF幻影非法字符,已经做了1.5个小时了,我简直不知所措 --submit.js-- $(document).ready(function() { $(function() { $('#paycheck').bind('submit', function() {

有人能看一下这些吗,这对我来说只是一个html表单,一个处理它的php文件和一个javascript文件,from浏览器中的错误显示了一些东西,比如JScript文件中的U+12AF幻影非法字符,已经做了1.5个小时了,我简直不知所措

--submit.js--

    $(document).ready(function() {
    $(function() {
        $('#paycheck').bind('submit', function() {
            $.post('Paycheck.php', $("#paycheck").serialize(), function(data) {
                $('#result').html(data);
            });
        });
    });
});

    --Paycheck.html--
    <!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <pre><title>Weekly Gross Paycheck Calculator</title></pre>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="submit.js"></script>
  </head>
  <body>

    <h2 style = "text-align:center">PayCheck</h2>
    <form name="paycheck" id="paycheck" action="" method="POST"> 
    <p>Number of Hours: <input type="text" name="numHours"/></p> 
    <p>Hourly Wage $<input type="text" name="hourlyWage"/></p>


    <p><input type="reset" value="Clear Form" />&nbsp;&nbsp;
    <input type="submit" name="submit" value="Send Form" /></p>
    </form>
<!-- Form and javascript will output the results  here -->
<div id="result"></div>

</body>
</html>


--Paycheck.php--

<?php
function validateInput($data, $fieldName){
    global $errorCount;
    if (empty($data)) {
        echo "\"$fieldName\" is a required field.<br/>\n";
        ++$errorCount;
        $retval = "";
    } else { // Only clean up the input if it isn't empty
        if (!is_numeric($data)){
            echo "\"$fieldName\" must be numeric.<br/>\n";
            ++$errorCount;
            $retval = "";
        }else{
        $retval = trim($data);
        $retval = stripslashes($retval);
        }
    return($retval);
    } // end validateInput()
}
$ShowForm = TRUE;
$errorCount = 0;
$numHours = "";
$hourlyWage = "";
$wage = "";

if (isset($_POST['Submit'])) {
    $numHours = validateInput($_POST['numHours'],"Number of Hours");
    $hourlyWage = validateInput($_POST['hourlyWage'],"Hourly Wage");
    if ($errorCount==0)
        $ShowForm = FALSE;
    else
        $ShowForm = TRUE;
}
echo $numHours ." " . $hourlyWage;
if ($ShowForm == TRUE) {
    if ($errorCount > 0)// if there were errors
        print  "<p>Please re-enter the form information below.</p>\n";
} else {
//If hours are over 40 then use time and a half
    if($numHours > 40) { $wage = ((($numHours - 40) * 1.5) * $hourlyWage) + ($hourlyWage * 40); }
//otherwise use normal multiplication.
    else { $wage = $numHours * $hourlyWage; }
    print "<p>Your weekly gross salary is $". $wage . ".</p>\n";
}

?>
-submit.js--
$(文档).ready(函数(){
$(函数(){
$('#paycheck').bind('submit',function(){
$.post('Paycheck.php',$(“#Paycheck”).serialize(),函数(数据){
$('#result').html(数据);
});
});
});
});
--Paycheck.html--
每周工资总额计算器
薪水
小时数:

小时工资$

--Paycheck.php--
您确定php脚本中的最后一行吗?我的意思是,美元符号不应该像这样消失吗

$(document).ready(function() {
    // don't double wrap
    $('#paycheck').bind('submit', function() {
        $.post('Paycheck.php', $("#paycheck").serialize(), function(data) {
            $('#result').html(data);
        });
    });
});
2)


每周工资总额计算器
有几件事:

js中有一个额外的嵌套lambda函数,这不是必需的

表单上没有任何操作,请更改为
action=“Payment.php”

在php脚本中,第27行应该是
if(isset($_POST['submit']){
(submit中小写为s)


在这些更改之后,一切似乎都正常工作。

您在文档中包装了两次准备就绪…这是我第一次看到
应用于标题。有人能告诉我它是做什么的吗?@ajax333221它什么也没做lol我试图让它以某种方式显示代码块,但后来我找到了ctrl+KIm的参考renceError:尝试使用jscript时未定义数据:|这可能是因为在加载JQuery时,您没有准备好#paycheck元素。请尝试使用
live
而不是
bind
。当我看到引用时,我要查找什么错误:数据未定义您是否有来自web服务的实时internet连接er?(远程加载jQuery时)欢迎您查看我这里的内容,当我在firefox中查看opera dragonfly/firebug的数据时,我看到了错误。啊,这是因为您的jQuery include指向了一个过期/损坏的地址。使用google cdn:正如前面所述,上面的代码在更改后没有错误,并且使用了一个实时jQuery库。所以ng肯定还是不一样。。。
$(document).ready(function() {
    // don't double wrap
    $('#paycheck').bind('submit', function() {
        $.post('Paycheck.php', $("#paycheck").serialize(), function(data) {
            $('#result').html(data);
        });
    });
});
<head>
<title>Weekly Gross Paycheck Calculator</title>
<!-- no pre tags -->
<script type=...
$(document).ready($(function() {
    $('#paycheck').bind('submit', function() {
        $.post('Paycheck.php', $("#paycheck").serialize(), function(data) {
            $('#result').html(data);
        });
    });
});