简体   繁体   中英

get data from database using AJAX

I have a code block. It does get method in typescript. but now I need to do the same with ajax and I couldn't adapt it. It has to be with js.

ts file example:

getProjects() {
    const body = {
      "Token": "111111111111",
      "DataStoreId": "1111111111",
      "Operation": "read",
      "Encrypted": 1,
      "Data": "select * from \"example\".exa.ex"
    }
    return this.http.post(baseUrl + 'Applications/DataOps', body).pipe(
      map((response: any) => {
        return response.message
      })
    );
  }

i need these parameters(token,DataStoreId,operation,encrpyted,data) in body for ajax. and it must be javascript.

I wonder why you need to run this using ajax. Usually database access should be done from the backend, doing it from the frontend would expose sensitive data like query and token to any client.

Anyways, I think more information is needed to help you. Which is the error you are seeing? Which is the database and its structure? Which is the code running on that endpoint?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM