Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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 Jquery ajax表单提交响应自动获取警报_Php_Ajax_Jqueryform - Fatal编程技术网

Php Jquery ajax表单提交响应自动获取警报

Php Jquery ajax表单提交响应自动获取警报,php,ajax,jqueryform,Php,Ajax,Jqueryform,我正在尝试使用ajax表单上传图像。图片上传成功。但是ajax响应会自动得到警告,弹出一个空白的窗口,上面写着“www.xxx.com上的页面上写着” 这是我的jQuery代码 $('#profileImg').die('click').live('change', function() { $("#profileform").ajaxForm({target: '#preview_profile', beforeSubmit:function(){ $("#profi

我正在尝试使用ajax表单上传图像。图片上传成功。但是ajax响应会自动得到警告,弹出一个空白的窗口,上面写着“www.xxx.com上的页面上写着”

这是我的jQuery代码

$('#profileImg').die('click').live('change', function()         
{
$("#profileform").ajaxForm({target: '#preview_profile', 
 beforeSubmit:function(){ 
 $("#profileloadstatus").show();
 $("#profileloadbutton").hide();
 }, 
success:function(s){
 $("#profileloadstatus").hide();
 $("#profileloadbutton").show();
}, 
error:function(){ 
 $("#profileloadstatus").hide();
 $("#profileloadbutton").show();
 $('#profileform').reset();
} }).submit();
if(!s)
{
    $("#profileform")[0].reset();
}
});
HTML表单

<div id="preview_profile"></div><form id="profileform" method="post" enctype="multipart/form-data" action='message_profile_ajax.php'>
                    <div id="preview_prof"></div>
                    <div id="profileloadstatus" style="display:none; text-align:center;">
                                    <img src='images/wall_icons/ajaxloader.gif'/> Uploading....
                                    </div>
                     <div id="profileloadbutton">               
                     <input type="file" id="profileImg" name="profileImg">
                     </div>
                     <input type="hidden" id="profvalues" value=""  />
                     </form>

正在上载。。。。
Php代码

<?php
include_once 'includes.php';


function getExtension($str) 
 {

     $i = strrpos($str,".");
     if (!$i) { return ""; } 

     $l = strlen($str) - $i;
     $ext = substr($str,$i+1,$l);
     return $ext;
 }

 function getImangeName($str) 
 {

     $i = strrpos($str,".");
     if (!$i) { return ""; } 

     $l = strlen($str) - $i;
     $ext = substr($str,0,$i-1);
     return $ext;
 } 

$valid_formats = array("jpg", "png", "gif", "bmp","jpeg","PNG","JPG","JPEG","GIF","BMP");
if(isset($_POST) and $_SERVER['REQUEST_METHOD'] == "POST")
    {
        $name = $_FILES['profileImg']['name'];
        $size = $_FILES['profileImg']['size'];

        if(strlen($name))
            {
                 $ext = getExtension($name);
                 $imageName = getImangeName($name);
                if(in_array($ext,$valid_formats))
                {
                if($size<(1024*1024))
                    {
                        $actual_image_name = $imageName.time().$uid.".".$ext;
                        $tmp = $_FILES['profileImg']['tmp_name'];
                        if(move_uploaded_file($tmp, $profile_path.$actual_image_name))
                            {
                                 $data=$Wall->Profile_Image_Upload($uid,$actual_image_name);
                                 if($data)
                                {

                                     echo '<img src="'.$profile_path.$actual_image_name.'" class="img-circle" alt="User Image" />';

                                }
                            }
                        else
                         {
                            echo '<b>Sorry, </b>Falied to upload your file!';
                         }
                    }
                    else
                    echo '<b>Sorry, </b>Image file size must be less than 1 MB!';
                    }
                    else
                    echo '<b>Sorry, </b>Invalid file format!';  
            }

        else
            echo '<b>Sorry, </b>Please select image..!';

        exit;
    }

请帮忙


谢谢

查看jquery.wallform.js

        //return data;
        // Modification www.9lessons.info
        var exp = /<img[^>]+>/i;
        expResult = data.match(exp);
        if(expResult == null) {
            alert(data);
        } else {
            $(options.target).prepend(data);
        }
       $("#photoimg").val('');
       // Modification End www.9lessons.info
//返回数据;
//修改www.9lessons.info
var exp=/]+>/i;
expResult=data.match(exp);
if(expResult==null){
警报(数据);
}否则{
$(options.target).prepend(数据);
}
$(“#photoimg”).val(“”);
//修改结束www.9lessons.info

调用警报的可能不是此代码。你能在
message\u profile\u ajax.php
中显示代码吗?你有其他相关的JS代码吗?我已经检查了包含的JS文件。其中没有其他警报。已经用消息\u profile\u ajax.php代码更新了问题这看起来不像所有的JQuery…声明的
s
变量在哪里?