...

View Full Version : Run SQL in javascript



supersav144
12-15-2010, 12:40 PM
I am quite new to using javascript and am currently trying to create a real-time username checker. Once the user enters the username I would like some javascript to run and check whether the username is already in the database, then if it is return 'this is already in use'.

Unfortunately I am not able to use ajax.

I would be very grateful for any help with this matter, and any example code would be much appreciated.

Phil

abduraooft
12-15-2010, 01:05 PM
Unfortunately I am not able to use ajax.There's no way other than Ajax to run a serverside process using javascript.

DJCMBear
12-15-2010, 01:09 PM
Why can't you use AJAX, why not research how to do AJAX and then you can use it to do the real-time username checker.

supersav144
12-15-2010, 01:34 PM
Why can't you use AJAX, why not research how to do AJAX and then you can use it to do the real-time username checker.

Unfortunately the server I'm using only allows for php, and ajax does not seem to run on it.

abduraooft
12-15-2010, 02:37 PM
Unfortunately the server I'm using only allows for php, and ajax does not seem to run on it.
It seems like you are unaware of Ajax!

Old Pedant
12-15-2010, 08:45 PM
http://www.w3schools.com/php/default.asp

Look down the page to the section title "PHP and AJAX".

Or just start here:
http://www.w3schools.com/php/php_ajax_intro.asp

alexma12345
12-16-2010, 09:35 AM
First of all, AJAX is not a language. You don't care what type of server side language you use.

Since PHP can generate XML as result to clients' browser and client's browser allow creating http request object with javascript there shoudnt be a problem with AJAX programming

If you really have to do something like AJAX's background http requesting without using the normal http object then consider making an invisible IFrame but its definitely not a good choice.

Old Pedant
12-16-2010, 07:55 PM
consider making an invisible IFrame but its definitely not a good choice.
Why not?

I did this as far back as 1998, before AJAX existed, and it worked great then. It still works great today. The big advantage is that it's much easier to debug with invisible IFrames, as you can simply turn the iframe visible while debugging and then do a view==>>source to see what's there. Plus it's often simpler to code. For example, if you want to send the contents of a <form> back to the server, all you have to do is
<form target="MyInvisibleIFrame" method="post">
and submit the form. No need to encode the values by hand; let the browser do it for you.

No, it's not a good solution for working with any prepackaged library. Clearly the code done this way is only going to work in one particular circumstance. But what's wrong with that, if you are creating a highly specialized system in the first place?

DJCMBear
12-16-2010, 08:04 PM
Unfortunately the server I'm using only allows for php, and ajax does not seem to run on it.

The server can't turn the usage of javascript off as it's a client-side language and since AJAX is a form of Javascript coding only the client can decide to have it turned on or off with their browser options, the server can decide what "server-side" languages to allow but (x)html, xml, css, javascript basicly all client side languages are standard, the server can decide to allow a file format which with javascript being so widely used in mark-up the blockage of .js files will never stop the developer from using javascript as they can just write the codes in the html or php files, so there isn't any way to stop the usage of it.

rnd me
12-16-2010, 11:16 PM
you can use other things besides ajax to talk to php.

1. use an image ping and php's gd to set the width of the returned image; 1=no user, 5=user exists.

2. use a dynamic <script> tag in conjunction with a jsonp response from php's json_encode.

3. use cookies and iframes.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum