我正在堆栈:最大调用堆栈大小超出错误

时间:2018-06-08 05:47:35

标签: javascript html css json api

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
</head>
<body>

<h2>HTML Forms</h2>

<form  name = "test_form">
  First name:<br>
  <input type="text" name="firstname" value="Mickey">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse">
  <br><br>
  <input type="button" value="Submit" >
</form>

<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
<script>

var url = "http://x.x.x.x:3001/createData"
var data ={
    "productID": document.test_form.firstname,
    "title": document.test_form.lastname,


};
var success_func = function(data){
    //do what you want with the returned data
 console.log("your data is succesfull posted")
};
$.post(url, data, success_func);

</script>
</body>
</html>

我不是通过任何东西也只是调用其余的api并发布数据,但我得到的堆栈最大尺寸除了错误请帮助我

2 个答案:

答案 0 :(得分:0)

在您的代码中尝试此操作并检查它是否有效

function goodCall(){
  var url = "http://34.201.147.118:3001/createData"
  var data ={
    "productID": document.test_form.firstname.value,
    "title": document.test_form.lastname.value,
  }
  $.post( url, function( data ) {
    sucess_func();
  });
};

function success_func(data) {
  console.log('data posted')
};
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>HTML Forms</h2>

<form  name = "test_form">
  First name:<br>
  <input type="text" name="firstname" value="Mickey">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse">
  <br><br>
  <input type="button" onClick="goodCall()" value="Submit" >
</form>

<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>

答案 1 :(得分:0)

试试这个我现在的工作

&#13;
&#13;
function fck(){
debugger;
var url = "http://34.201.147.118:3001/createData"
var data ={
    productID: $("#txt1").val(),
    title: $("#txt2").val(),


};
var success_func = function(data){
    //do what you want with the returned data
 alert("your data is succesfull posted")
};
$.post(url, data, success_func);
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<h2>HTML Forms</h2>

<form  name = "test_form">
  First name:<br>
  <input type="text" name="firstname" value="Mickey" id="txt1">
  <br>
  Last name:<br>
  <input type="text" name="lastname" value="Mouse" id="txt2">
  <br><br>
  <input type="submit" value="Submit" onclick="fck()">
</form>

<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
&#13;
&#13;
&#13;