Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

128
Views
Difference between jQuery and Axios PUT request

I am new to web development and I am working with a system that needs overhauling and development.

I am attempting to pull what is saved on a server as a "JSON" file to the front end and display the encoded data.

The "JSON" file includes text like the following:

{"name": "7.8-15.6kHz",data: [  [Date.UTC(2021, 9, 29, 0, 30, 12),0], [Date.UTC(2021, 9, 29, 0, 30, 12),0], [Date.UTC(2021, 9, 29, 1, 30, 59),0], [Date.UTC(2021, 9, 29, 2, 30, 17),0], [Date.UTC(2021, 9, 29, 3, 30, 15),0],

EDIT: I put "JSON" in quotes because this isn't json, however the file I am grabbing has a .json extension. This is the output of a microprocess somebody else wrote, and I am hoping to use this "JSON" file to pull data on the front end without having to manipulate the microprocess.

This obviously includes Javascript objects (passed as strings via php), as well as strings, and integers.

When I request this data via jQuery, the response is formatted as a Javascript object without needing to do anything to the response:

$.ajax({url:dataHTTP,
     dataType: "json",
     type:"POST",
     data:user,
     success:function(returnedData){
          console.log(returnedData)
          //Do some stuff with returnedData
}})

As I am migrating to REACT, I am trying to achieve the same with Axios:

const config = {
     headers: {
          'content-type': 'application/json'
     }
 }
axios({
     method: 'post',
     url: dataURL,
     data:JSON.stringify(this.state.user),
     headers:config.headers
}).then((res) => {
     console.log(res.data); //this logs a string of the "JSON" file
     JSON.parse(res.data); //this throws an error
      
})

What is the difference here and how can I force Axios to treat this the same way as jQuery does??

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!