skip to Main Content

i’m a noob of jquery and i have to pass a variable from js to php

I’write this code in the js pages

$.ajax({
  url: "../php/inserimentoPresenze.php",
  type: "GET",
  data: {presenti : pkpresenti },

  error: function () {
    alert("Errore");
    document.body.style.cursor = "pointer";
  },
});

the php page have this code

<?php 
print_r($_GET);
?>

the jquery error in this line (9930)

xhr.send( options.hasContent && options.data || null);

the url is right but the code dosen’t work. Is really strange because i have used this code in other site and it work.

I don’t know why i have this problem. Please help!!

2

Answers


  1. try asking chat gpt, e vedi che ti dice

    Login or Signup to reply.
  2. First of all I suggest you to do some fixes.

    • You’re doing a GET request so you cannot put any data payload with it.
    • If you need to pass some data within your request, you should use POST and you’re gonna fetch it in your php page using the $_POST var.

    You have to do some checks to be sure you are reaching the php file with your request. Try to send your request with your Network tab opened so that you can see, when you click on the request, the Request url of your request and make sure that it’s valid and try to navigate it.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search