小编Anu*_*ngh的帖子

如何在php中读取FormData对象

大家好,我发布了一个示例代码,我在其中使用Ajax JQuery上传文件.一切正常,但我想在我的PHP代码中读取文件内容.那么阅读它的语法是什么?

    <?php

?>

<!--================================html==================================================-->

<html>
<head>
    <title>AJAX UPLOAD</title>
    <script type="text/javascript" src="jquery-2.0.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#Button_').click(function(){
                alert("hi");
                var name= document.getElementById('File_');
                 var alpha=name.files[0];
                console.log(alpha.name);
                 var data= new FormData();
                 data.append('file',alpha);
                 $.ajax({
                 url:'process.php',
                 data:data,
                 processData:false,
                 contentType:false,
                 type:'POST',
                 success:function(msg){
                 alert(msg);
                 }
                 });
            });
        });
    </script>
</head>
<body>
    <input type="file" name="File" id="File_"/>
    <input type="button" name="Button" id="Button_" value="UPLOAD">
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

现在我不知道如何读取通过Ajax发送的文件数据.所以请让我知道代码

javascript php jquery

18
推荐指数
1
解决办法
5万
查看次数

从Eclipse运行Tomcat时出现HTTP错误404

我已经安装了Eclipse和Tomcat 7.错误是当我从Eclipse运行Tomcat时它会启动,但之后,当我localhost:8080在Google Chrome中打开时,我得到了HTTP Error 404().我该怎么解决这个问题?

eclipse tomcat servlets

17
推荐指数
3
解决办法
10万
查看次数

如何使用单个JOptionPane.showMessageDialog()语句显示多个输出?

如何使用显示多行JOptionPane.showMessageDialog().例如,我在下面发布一个例子.现在,在下面所述的示例中,a1,b1,c1必须使用" JOptionPane.showMessageDialog()是否有任何方式在一个窗口中显示所有值"逐个显示值?因为在下面的例子中,三个窗口将一个接一个地出现.

class demo()
{
    public static void main(String args[])   
    {
          String a=JOptionPane.showInputDialog(null,"Enter a number");
          int a1=Integer.parseInt(a);
          String b=JOptionPane.showInputDialog(null,"Enter a number");
          int b1=Integer.parseInt(b);

          int c=a1+b1;
          JOptionPane.showMessageDialog(null,a1);
          JOptionPane.showMessageDialog(null,b1); 
          JOptionPane.showmessageDialog(null,c1);
    } 
}
Run Code Online (Sandbox Code Playgroud)

java swing joptionpane

4
推荐指数
2
解决办法
2万
查看次数

服务人员skipWaiting无法激活当前正在等待的软件

描述:

我们正在使用sw precache预先缓存脚本,因此要更新脚本,我们提供了reload选项,因为我们正在监听工作程序消息,以跳过由于未知原因而等待新安装的服务工作程序的问题,我们无法正确执行

importScript

// GETTING OLD SW reference (self) and NOT getting newly installed SW reference

self.addEventListener('message', function(event) {
    *// not working*
    self.skipWaiting();
});



// But if we put skipWaiting() in 'install' listener 
// it is getting correct new SW reference and working correctly

self.addEventListener('install', function(event) {
    // self.skipWaiting();
});
Run Code Online (Sandbox Code Playgroud)

软件注册

if('serviceWorker' in window.navigator) {
      window.addEventListener('load', function() {
        window.navigator.serviceWorker.register("/serviceWorker.js").then(function(registration) {
          console.log("ServiceWorker registration successful with scope: ", registration);
          registration.onupdatefound = function() {
            console.log('NEW WILD WORKER HAS SPAWNED.!', registration);
            var installedWorker …
Run Code Online (Sandbox Code Playgroud)

reactjs service-worker progressive-web-apps sw-precache sw-toolbox

4
推荐指数
1
解决办法
5510
查看次数

如何将PHP变量值分配给JavaScript变量

在我发布的这段代码中我有一个问题.我希望我的PHP变量存储在JavaScript变量中,但它显示错误.代码如下.

<?php
    $name="anurag singh";

    echo '
        <html>
            <head>
            <script type="text/javascript" src="jquery-2.0.2.js"></script>
            <script type="text/javascript">
                $(document).ready(function(){
                    var name1=.$name.";"
                    $.post("main_page.php",{input1: name1}, function(msg){
                        alert("hi "+msg);
                    });
                });
            </script>
            </head>

            <body>
                <h1>This is the demo!</h1>
                <h2>In echo we can add more than one statements</h2>
            </body>
        </html>
    ';
?>
Run Code Online (Sandbox Code Playgroud)

现在,当我分配$name给变量时name1,我得到的语法错误.请让我知道我必须做出哪些改变.这样我就可以获得$name存储在JavaScript变量中的PHP变量的值name1.

html javascript php jquery

1
推荐指数
1
解决办法
1万
查看次数

这个JavaScript引用

今天我在写一些java脚本的基本内容时遇到了问题.虽然我能够解决问题,但找不到为什么这不起作用的原因.这是我的代码

$('document').ready(function() {
     $(this).click(function() {
         var node1 = $(this);
         a = node1.text();
         console.log(a);
     });
 });
Run Code Online (Sandbox Code Playgroud)

在控制台中我看到空字符串.但是,如果我更改$(this).click(function{...})$('.some_class_name').click(function{.....});我的代码工作正常,并显示我单击按钮的文本值.我想知道上面的代码有什么问题.

javascript jquery

1
推荐指数
1
解决办法
74
查看次数

无法使用Jquery隐藏div元素

在我的代码中,我试图隐藏包含图像的div元素,但是当我运行代码时,我得到了 - ReferenceError:jQuery未定义})(jQuery); 在文件jquery-ui.js中(第314行).我的代码如下

<!DOCTYPE html>
<html>
<head>
    <title>Sliding a div</title>
    <script type="text/javascript" src="plugin/ui/jquery-ui.js"></script>
    <script type="text/javascript" src="plugin/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
            $('#1').click(function(){
                console.log("i am inside");
                $('#element').hide('slide',{direction:'left'},1000);
            });
        });
    </script>
</head>
<body>
<div id="headder" style="width: 1300px; height: 100px">
    <h1>Slide the div</h1>
</div>
<div id="element" style="width: 600px; height: 400px; border: 2px solid red; position: relative">
    <img src="images/aa.jpg" width="600" height="400">
</div>
<div id="control" style="position: relative">
    <input type="button" id="1" value="PRESS">
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

请让我知道这背后的原因.

html javascript jquery jquery-ui

0
推荐指数
1
解决办法
474
查看次数

为什么"hello"在布尔条件下评估为true?

我一直在用C语言工作,因为它是我开始的第一语言.这次我正在用if else语句做一些编码......我发现了一些我无法理解为什么会发生的事情.代码如下跟随

#include<stdio.h>
#include<conio.h>

void main()
{
    printf("How If - Else works\n");

    if("hello")
    {
        printf("Inside if\n");
    }
    else
    {
        printf("Inside else\n");
    }

    getch();
} 
Run Code Online (Sandbox Code Playgroud)

在这里输出是Inside if ....我想知道如何在if语句中对这个东西进行求值,并且对if语句中传递的内容有任何限制.

c if-statement boolean

0
推荐指数
2
解决办法
173
查看次数