小编Tur*_*tel的帖子

更好地取消设置多个数组元素的方法

这里的交易是我有一个包含17个元素的数组.我希望在一定时间内获得我需要的元素,并从阵列中永久删除它们.

这是代码:

$name = $post['name'];
$email = $post['email'];
$address = $post['address'];
$telephone = $post['telephone'];
$country = $post['country'];

unset($post['name']);
unset($post['email']);
unset($post['address']);
unset($post['telephone']);
unset($post['country']);
Run Code Online (Sandbox Code Playgroud)

是的,代码很难看,不需要打击.如何让这个看起来更好?

php

72
推荐指数
3
解决办法
6万
查看次数

Jquery Ajax响应

当我使用Jquery执行ajax请求时,从PHP获取响应的正确方法是什么?

我有这个代码用于Jquery:

$('#quote-form').submit(function(e) {
    e.preventDefault();
    $.ajax({
        type: 'POST',
        data: $(this).serialize(),
        dateType: 'json',
        url: 'mail.php',
        success: function(data) {
            alert(data.msg);
        }
    });

    return false;
});
Run Code Online (Sandbox Code Playgroud)

和PHP代码mail.php:

// Some mail functions here

$mailSent = @mail($to, $subject, $message, $headers); 
$return['msg'] = $mailSent ? 'mail sent' : 'mail failure';  
echo json_encode($return);
Run Code Online (Sandbox Code Playgroud)

我试图提醒响应alert(data.msg)但是它说未定义.有什么想法吗?

php jquery

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

标签 统计

php ×2

jquery ×1