Jquery帖子......没有发布任何内容

时间:2017-03-21 17:39:26

标签: javascript php jquery ajax

我有一个通过ajax发送电子邮件的表单,该表单已经运行了多年。突然间,什么都没发布,我不明白为什么。

THE JS:

inset_axes

Process.php:

import matplotlib.pyplot as plt
import mpl_toolkits.axes_grid1.inset_locator as il

fig, (ax1, ax2) = plt.subplots(nrows=2, figsize=(4,4))
ax1.plot([1,2,3],[2.2,2,3])

# set the inset at upper left (loc=2) with width, height=0.5,0.4
axins = il.inset_axes(ax1, "50%", "40%", loc=2, borderpad=1)
axins.scatter([1,2,3],[3,2,3])

# set the inset at 0.2,0.5, with width, height=0.8,0.4 
#   in parent axes coordinates
axins2 = il.inset_axes(ax2, "100%", "100%", loc=3, borderpad=0,
    bbox_to_anchor=(0.2,0.5,0.7,0.4),bbox_transform=ax2.transAxes,)
axins2.scatter([1,2,3],[3,2,3])

plt.show()

每次我使用表单时,ajax“有效”,但“ 没有发布 ”出现。我找不到解释...... 有关信息,我使用Jquery 3.1.1和PHP 7.0

3 个答案:

答案 0 :(得分:0)

实现jQuery ajax的正确方法是:

var name = $("input#name").val();
var email = $("input#email").val(); 
var telephone = $("input#telephone").val();
var message = $("textarea#message").val(); 
$.ajax({  
type: "POST",  
url: "process.php",  
data:{
 name:name,
 email:email,
 phone:phone,
 message:message
},  
}); 

而php应该是:

<?php
  if ($_POST) {
    $name = $_POST['name'];
    echo $name;
  }

  else {
    echo 'Nothing is posted'; 
  }
?>

答案 1 :(得分:0)

jQuery在版本1.9中将​​type更改为method。尝试将ajax调用更改为:

$.ajax({  
  method: "POST",  
  url: "process.php",  
  data: ...
});

答案 2 :(得分:0)

试试这个:

    if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
      // POST
    } else {
      // GET
    }
相关问题