Run db query (sql server 2005) with ajax. Is it possible?

前端 未结 3 1104
庸人自扰
庸人自扰 2020-12-18 17:11

I never worked with ajax.

I need to know if it is possible to use ajax to run a query on the db (sql server 2005).

My target is to run a query with refreshin

3条回答
  •  萌比男神i
    2020-12-18 17:41

    AJAX => Client side PHP / ASP / X => Server side (databases as well)

    Basically, anything client side is happening "right now", whilst server side scripts "already happened".

    You can't perform a query to a database with JS or anything alike, AJAX is nothing but an user experience ilusion, even when we can speak of "fetching DB records through AJAX" that's not actually what's happening.

    If AJAX is just more JavaScript (Asynchronus JS, that is, happening in it's own "timeline" / thread, not the main one) then that would mean that fetching data from a DB (or doing anything through AJAX for that matter) would be the same as having a link to scripts that statically do that, meaning, you click here, you're taken to a page that fetches (server side) and displays (client side) the information.

    Now imagine that you just do exactly that, but instead of taking your main thread to that action, you fire an asynchronus thread (that will work just as any other link, for instance) which will post/get data and get an X response, which you can handle through JS later on, thus, giving you the ilusion of "real time queryes".

提交回复
热议问题