I have a field on my form, which I'd like to parse before sending to a Web server. Is it possible by using C functions provided by the web server?
I mean, suppose I have parse_field() function written in C, and the web server knows it and can call, so I do something like <% parse_field() %> on the page, the function shouls take the current contents of the field as an argument and return some parsed value, which will be POSTed to the server.
Is it possible, or not by all means? Or it is better to do with JavaScripts function (but I'm not very good with JS though :( )?
Thanks !
Is this classic ASP?
I wouldn't rely on Javascript for validation. You can't assume that everyone has JS enabled. You should implement server-side validation for graceful degradation, and then implement JS for client-side validation.
I'd suggest JavaScript, since it is server sided. Maybe you are trying to validate something? Have a look at this: http://flowplayer.org/tools/demos/validator/index.html
Related
I have a requirement where I have to get data from another server .. The server supports only JSON and not JSONP. How can I get the data from the server using JSONP?
I am doing it in jquery..
Is there any other solution to it?
Kindly help me..
The reason why JSONP exists is to get around the cross-domain issue with Javascript. This basically means that javascript in your browser shouldn't be allowed to talk to webservices that's not on the same domain as your web application.
JSONP makes this cross-domain integration possible because your browser and the server have an "agreement". You give it a callback, and it gives you the result, wrapped in that callback. It expects to be called via javascript so there's less of a security risk involved.
Example:
You call http://www.abccorp.com/index.php?callback=somevalue
Without JSONP, you'd get back:
{ some: 'value' }
With JSONP:
somevalue({ some: 'value' });
If a server does not support this callback, it's just not possible (by only using javascript).
I recommend using a server-side programming language that can facilitate this call for you.
For example, you have a PHP file called index.php. Your javascript would call this file using an AJAX JSON request. In turn, it would call the server you need, get the results, and forward them to the javascript. Since you're not using javascript, this server-side programming does not need a callback (or agreement) like javascript does.
I don't understand. I have searched all internet forums but found nothing helpful. I am trying to update the numberOfLikes field on my postsTable in MySql when the user clicks on the like button. I know this is done through ajax but I am only familiar with prototype ajax and none internet forums state anything about it.
Here's the flow chart
1. On "seeForums.php" user clicks on the "like" link.
2. The like link has an id that triggers the function which updates numberOfLikes on my postsTable.
Thats it. Thats all I need. But I need it in a prototype ajax format, something like this.
function processLikes()
{
new Ajax.Request(theUrl,
{
contentType:"text/HTML",
onSuccess:updateLikesMySql,
onFailure:error
onException:error,
});
}
Helps are appreciated :)
You can't do this with Javascript alone as it is client side only, you'll need to get a server side language (e.g. PHP) involved as well.
The idea is that you send an AJAX request to your PHP file along with the data that you want to update, and your PHP file will handle inserting values into the database. That PHP file would then print an output (e.g. success or failure) which would be received in your Javascript so you can act accordingly.
You should know that the nature of HTTP (web) makes it Request/Response like.
So your backend code runs on the server,
And javascript and all frontend code run on the client.
Client has no access to your database, So you can't do anything to your database with Javascript.
Best thing you can do is ask your serve with javascript to update the database,
Make a server-side script available at some URL,
Then use ajax to call that URL.
In the server-side script, do the code which updates the database.
Is there any way to send data from one HTML page to another using basic HTML without using JavaScript and PHP?
It's easy to "send" data:
Send
but there is no way for the receiving page to parse it without a server-side application or JavaScript. (Or Flash, or a Java applet, or an ActiveX control....)
html only purpose is to show content. It is not designed for getting and passing data. you need server side script to do that.
Good answers. Pekka and Andre really nailed it.
In order to pass data from HTML form fields to your web application:
1) You can manually build a link with query string variables (basically Pekka's example)
Submit
2) Or, to retrieve data typed in by the user (which is typically what you want), you can use the GET method
<form action="signup.pl" method="get">
Name: <input type="text" name="name" />
<input type="submit" />
</form>
Either way, you end up with a post to the web server with the same URL (provided the user typed "john"):
http://www.mycatwebsite.com/signup.pl?name=john
(or you can use POST instead of GET, but then query string variables don't show up in the URL)
But in order to read and process it, as already mentioned, you need a server side programming language.
Even the first dynamic websites back in the 90's used CGI Perl scripts, or even ANSI C, to process data. Here's a simple Perl example:
HTML Forms POST, GET
Now of course there are many web application languages (and frameworks) to choose from, such as PHP, Java, ASP.NET, Ruby, Python, etc. But they all adhere to the CGI convention of passing data back and forth (CGI Request/HTML response) between the web server (Apache, IIS) and the web site.
Common Gateway Interface
Dynamic website
You can prompt the user to enter data with a <form>, and you can add GET-query-parameters to your URL (index.php?foo=bar). But to work with the received data, you will need to use a programming language.
You can send data but can't process sent data. For it you must use PHP, javascript or something similar...
A project requirement is that it be 1 way deeplinkable(a specific query string will load a section within the swf).
I have a URLProxy that I use for all external linking.
It makes sense to me to put the query string logic in this proxy.
So in the constructor, I check for a querystring, and then send a notification if it equals a predefined value.
One problem with this is that I'd like to predefine this query string key value I am checking against in an external xml file.
So another proxy, loads-parses this config xml, then the URL proxy checks against this.
Is there a better approach to what I am trying to do?
not very clean question for me, if you can please explain more detailed,
and for now:
maybe there are some sense to send something like GET\POST or just variables to your proxy, but where from you are calling it, its another one question to you.
I'm a little late to the party here, but if anyone needs this, you should use swfAddress to deep link in to flash via the url.
https://github.com/danro/swfaddress-as3/blob/master/SWFAddress.as
I'm no expert on web development, and need to find a way to let the browser call a PHP routine on the server with the current document ID as parameter, eg.
http://www.acme.com/index.php?id=1
I then need to call eg. /change.php with id=1 to do something about that document.
Unless I'm mistaken, there are three ways for the client to return this information:
if passed as argument in the URL (as above), it will be available as HTTP referrer
by including it as hidden field in
by sending it as cookie
I suppose using a hidden field is the most obvious choice. Are there other ways? Which solution would you recommend? Any security issues to be aware?
Thank you.
You can also POST the data so it won't be seen in the URL with ’form method = "post" ’
All of these methods are, to a point, insecure as they can be manipulated by a savvy user/hacker. You could https your site, limiting any man in then middle attacks. Be sure to check and validate incoming data
Ajax is another option as well, and it allows you to send that information without refreshing the page.
http://www.acme.com/index.php?id=1
The above url would be more "browser friendly" if you transform it into something similar to this:
http://www.acme.com/index/page/1
I am sure you can achieve this in Apache. Or Java Servlets.