Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70435

HTTP POST {"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0}}

$
0
0

@basti wrote:

Hi, I want wo insert data on mysql. With the native HTTP plugin it’s no problem to insert data via GET.
But I want to do a POST request and there always just comes this strange error (couldn’t find something about this online):

{"__zone_symbol__currentTask":{"type":"microTask","state":"notScheduled","source":"Promise.then","zone":"angular","cancelFn":null,"runCount":0}}

Ionic code:

let postData = new FormData()
  postData.append('s_id',this.s_id)
  postData.append('klasse',this.klasse.id)
  postData.append('stunde',this.stunde.id)
  postData.append('uebungen',JSON.stringify(this.uebungen))
  postData.append('wo_id',woid)

const options = {
    headers: {
        'Content-Type': 'application/x-www-form-urlencoded'
    }
};

this.http.post(
      'URL.php/', 
      postData,
      options
     )
     .then(response => {
        // prints 200
        console.log("Response-Status: "+response.status);
        try {
          response.data = JSON.parse(response.data);
          // prints test
          console.log("Response-Message: "+response.data.message);
        } catch(e) {
          console.error('JSON parsing error');
        }
     })
     .catch(response => {
       // prints 403
       console.log("Response: "+JSON.stringify(response));
      }
     });

And here my PHP code to insert the values in mysql:

$neuer_user = array();
$neuer_user['s_id'] = $_POST['s_id'];
$neuer_user['klasse'] = $_POST['klasse'];
$neuer_user['stunde'] = $_POST['stunde'];
$neuer_user['user'] = $_POST['wow_id'];
$neuer_user['uebungen'] = $_POST['uebungen'];
 
$statement = $pdo->prepare("INSERT INTO wot (s_id,klasse,stunde,user,uebungen) VALUES (:s_id, :klasse, :stunde, :user, :uebungen)");
$statement->execute($neuer_user);

If I use this with GET it works, but with POST not…

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70435

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>