Laravel:我在使用Ajax发布数据时遇到了一些问题

Im new to using ajax and I have another post here about my code and they said it was correct. However Im still facing issues

My code:

body[circle.id] = {id: currentid-1, x: event.offsetX, y: event.offsetY};

// Ajax 
for(let i = 0;i < body.length;i++){
    $.ajax({                    
        url: 'get.php',     
        type: 'post', 
        data : {
            data: body[i],
          },
        dataType: 'json',                   
    });
}

The error: [Error][1]

According to the error image you have posted, The error says that the method only accepts the GET request but you are trying to make POST request in your AJAX method, Change your request type to GET like this,

$.ajax({                    
  url: 'get.php',     
  type: 'get', 
  data : {
    data: body[i],
  },
  dataType: 'json',                   
});

I cannot comment.

From the title I guess you are using Laravel.

I see you are hitting the file directly, but looks like you are showing only half the setup. In case Laravel. What is the route setup? And if the setup is like Route::get try Route::any. How are you debugging the issue? Do you have any logs? Can you check the logs of "web server"? Either artisan serve or php -S should give at least some hints what your ajax is hitting.

I fixed it.The problem was in url and routes