简体   繁体   中英

how to pull data from sql server api using Codeigniter or PHP

My sql server created api is given below

http://0.0.0.0/XHost/api/General/[{Employee_ID}]

Example: http://0.0.0.0/XHost/api/General/0123456789

I have a api with real ip like above.

I am using Codeigiter, I would like to pull/get data from sql server via api.

Basically i will use jquery autocomplete to pull data.

How can i solve it? please any suggestion.

Use the rest server class for this,

Download it from Codeigniter-restserver Read this for how to use it

And call your api from jquery like,

$( "#autiId" ).autocomplete({
   source: "http://0.0.0.0/XHost/api/General/0123456789",
   minLength: 2,
   select: function( event, ui ) {
      alert("Selected: " + ui.item.value + " id " + ui.item.id : "Nothing selected, input was " + this.value );
   }
});

If your emp id is dynamic then append by getting this like,

var id=0123456789;

and source like,

source:"http://0.0.0.0/XHost/api/General/"+id

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