How To Get Data From Server
Jul 23, 2005
What i want to do is that this function post data to the server (ASP) and
the server will response with 'OK' My question is how can i send data clientside from Javascript to the server ? (navigate ? with url ?)
and check the returned data in the same function ?
function ShowData(TxtArt)
{
alert(TxtArt + ' : ' + parent.frames.Bottom.TxtUsrName.value + ' - ' +
parent.frames.Bottom.TxtRemarque.value); // testing purpose
// post the data to the server. ex .. myURL.asp?userID=1000&Art=ART1201
// fetch the data from the server. to verify if the 'OK' is recieved ->
the server will response with 'OK'
// if 'ok' -> i will update clientside an frame (ex. contents of
shoppingbasket)
}
Any idea's ?
View 3 Replies
ADVERTISEMENT
May 18, 2011
TEST .js
// JavaScript Document
$.post('http://example.com/test.php?image_no='+no_image, function(data) {
$('#gallery').html(data);
[code]....
View 1 Replies
View Related
Jan 4, 2006
Read the first reply below first/instead, it's probably more helpful than this one
There's a lot of talk about AJAX these days and it seems to me it's turning into a hammer for a lot of problems that aren't really nails. If you want your pages to call home but don't want to have to deal with XML parsing and extremely spotty browser support, here's a very simple way to effect communication from Javascript to the server. The server can only (easily) communicate back on the next page hit with this method, but as a one way conduit from client to server post page rendering it can hardly be beat.
I've set it up with a really simple case that keeps track of the total time each user spends looking at a page in ten second increments. I have, for clarity (I hope) stuck it all in one PHP file, but it'll work the same with any server side language:
<?php
// this block isn't really too well coded or useful, it's intended more as a simple proof of concept
if (isset($_GET['ip']) && ip2long($_GET['ip']) !== false)
{
// if there's a GET variable (this.php?ip=something) and it appears to be a valid ip...
$fname = sha1($_GET['ip']) . '.time'
if (file_exists($fname) && strpos(($pre = file_get_contents($fname)), '='))
{
// if we have a file and it looks like it might be in the right format, increment the value contained therein
list($ip, $time) = explode('=', $pre);
file_put_contents($fname, $ip . '=' . ($time + 10));
}
else
{
// else just write it in and hope for the best
file_put_contents($fname, $_GET['ip'] . '=10');
}
/*
//actually returning an image here can help get the loading message out of browser's status bars
header('Content-type: image/gif');
fpassthru('small.gif');
*/
}
else
{
?>
<html>
<body onload="javascript:setTimeout('serverTick();', 10000);">
<script language="javascript">
var ip = '<?php echo $_SERVER['REMOTE_ADDR']; ?>' // give the javascript an ip or a hash or something to pass back that will be reasonably unique
function serverTick()
{
setTimeout('serverTick();', 10000); // call this function again in 10 seconds
var notshown = new Image();
notshown.src = '<?php echo $_SERVER['PHP_SELF']; ?>?ip=' + ip; // calls this file in attempt to preload an image, instead triggering the above block of PHP
}
</script>
</body>
</html>
<?php
}
?>
This will work in far more browsers than AJAX will, and it's not subject to any domain restriction, it can post to another server without generating security exceptions. It may be possible to get data back in the body of the image and it's definitely possible to get data back coded as image dimensions, if you want to push this method a little further.
View 5 Replies
View Related
Apr 13, 2010
how Google Analytics or Google Adsense lets you copy and paste javascript to your site and you can load data/track visitors/etc. Well, I want to do the same thing for my customers, on their domains, where they load dynamic prices on my server (long story). Is $getJSON the best solution in this day and age? I would prefer to not force them to use frames and I am not worried (nor are they, for reasons I wont' get into) about users who don't use javascript.
In short, our site processes payments for them and there is a unique feature that offers dynamic prices. So if they have javascript code with an order button image, I want them to hit my server and have their javascript code read my server, find the updated price, and display it to their user. note they will be using .html pages, not php, and they are not programmers and I want to simplify it.
View 3 Replies
View Related
Jul 23, 2005
I have a form whereby I can add multiple contacts to a single address.
There is only one firstname/lastname/telephone box - when the user
clicks the add button, I read the values from the form fields and
record them into a hidden text input field. This part works because
during debugging, I have converted the <input type=hidden> into a <input
type=text> to visably confirm my data is being copied into the 'hidden'
field.
Once the user has entered in one or more names, they can click another
button and submit the form for processing. My idea is that I would then
parse this hidden field server side...
I have a WAMPHP based server and as a test, I dump out my entire $_POST
(basically, the name and value in every INPUT tag).
My PHP script picks up the name of every input tag, including the hidden
field (like it should) but for some reason, the value that was written
to the hidden field is not passed to the server. Thus, for the PHP folk
reading this post, my hidden input field is called mylist and
$_POST['mylist'] exists, but its empty. Even though before processing,
I could visably see the input in the box (for debugging remember, I made
the input tag box a normal, unhidden one).
Here is what I have done to try and resolve:
- I have used both Mozilla 1.7.5 and IE6 - both provide same results -
my hidden field name gets passed, but not its value.
- I have created another hidden field and given it a default value ie I
have <input type="hidden" name="extraone" value="xyz"> and I get
$_POST['extraone']="xyz" passed to my php server, like I would expect -
however, the value of mylist is sent empty, even though it has data.
- I have even put in a javascript alert box just before the form is sent
to the server and can see the result in my (unhidden) box, and the same
value displayed in the javascript alert - but again, the value of the
mylist does not get sent to the server.
The only difference is that my hidden field (even if its displayed like
an ordinary text input box) does not post data written to form fields as
the result of a javascript function. Interestingly though, the server
does know about the input tag box since it does receive
$_POST['mylist'], it justs receives it empty.
What gives? If the form reads my input from one field, and writes it to
another field, then it should be sent to the server, true?
Also... my tags are all inside my <form></form> tag (which is proven by
double checking, and the fact that I do get the input tag box name sent
to my server).
Since I can see the data values in the box, it tells me my javascript is
doing what it should be doing - so I don't see any point in including my
javascript (though I have no problems doing so if someone requests
it). On the php server, I am using a simple phpinfo(); to check the
data is being received...
View 10 Replies
View Related
Apr 5, 2006
Do you know a dynamic way to send 10kb of text or more using an iframe?
I tried to do that with by creating, in javascript, a dynamic iframe,
then create a form into this iframe and put the data in a textarea and
then call a sumbit(). Code:
View 1 Replies
View Related
Mar 3, 2011
I have the following piece of code:
$.ajax({
data: someData,
url: submissionUrl,
[code]....
where someData is a vanilla object of key/value pairs, submissionUrl is a valid URL and ajaxSuccess/ajaxError are both functions.Using jQuery 1.5.1, the GET request is delivered to the server without the data. Using jQuery 1.4.4, the request contains the data.Has something changed in the way I should be assigning data to an ajax request in 1.5.1? The docs don't seem to suggest I'm doing anything incorrectly.
View 2 Replies
View Related
Sep 28, 2009
Here is what I am trying to do. On my web page, I have three choices for the user to pick from. After the user selects one of the checkboxes and clicks a submit button, I need to send a http request to a remote server to record the user's choices (actually it is an https that I am sending),.. so I need to send something like this.
[URL]
The remote server responds with an xml response that looks like this:
<?xml version="1.0" encoding="utf-8"?>
<sessionState>
<answer>True</answer>
</sessionState>
So, I want to post the request, read the response (answer) back from the other server and display it on my page. So, my dilemma is as follows:
1) my understanding is that I cannot do this with AJAX using an XMLHttp object because it is on a remote server and it would violate some sort of same-domain security. Is that correct? If in fact I can do it in AJAX, how do I read the response back from the other server?
2) if I am correct in my assumption in 1) then what is the best way to accomplish this task?
View 2 Replies
View Related
Feb 3, 2011
what I am trying to accomplish is done through javascript, but I think that it is.
I would like to access server-side data without refreshing the entire page. Is this done through layers somehow?
View 2 Replies
View Related
Apr 18, 2011
I am having trouble sending JSON data to a server. Its definitely reaching the parser.php, but I am not what to create in PHP to fetch this data. Also I am not sure my Javascript is correct.
<SCRIPT>
var JSONObject = new Object;
JSONObject.description = "hello";
JSONstring = JSON.stringify(JSONObject);
runAjax(JSONstring);
[Code]...
View 5 Replies
View Related
Jul 27, 2011
I am trying to send the login info from a form into a IIS server and the asp file on the server will just respond back with the following text "Welcome, &name" on a ajax form on the client side. Currently, i am using a GET response and would like to send using JSON instead.
html file on client side
Quote:
<!-- AJAX component-->
<!DOCTYPE HTML>
<html>
<head>
[Code]....
View 5 Replies
View Related
Jun 1, 2009
<div>Hi jQuery,</div>
<div> </div>
<div>I'm trying to learn the json and ajax</div>
[code]....
View 3 Replies
View Related
Dec 18, 2011
well i'm kind of new to this website and scripting with javascript but i am wondering: in a client side .js file i have some coding which results in a string which is stored in a variable called exportData
now i want that string to be written into a text file on a server but how do i do that? it is not local on the client's pc and i can't find how to do it anywhere..
View 4 Replies
View Related
Oct 11, 2010
I am using Ajax to send a large text box to a server script, however, when the textbox has a lot of data it fails. Is there a better way for me to do this? Here is my code.
Code:
<script type="text/javascript">
function testmail()
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
[Code]...
View 7 Replies
View Related
Apr 13, 2005
is there a way to send data to the server through a form , and then receive the response from the server without reloading a new page? kind of like the LoadVars object in flash?
View 2 Replies
View Related
Dec 14, 2009
I know at this point is that these is a difference in the array formatting between PHP and JS. The magic bullet is supposed to be json. However, this code does not work as advertised.
[Code]...
The variable $prt is list of associative arrays, so to get a value in a particular row manually , $prt[0]['location'] should give me the value for location in the first row of output. All of this works just fine if i hard code this in html and php. However, I want to dynamically produce the rows as needed which requires that a loop employed. The application also requires that the user may add a row which also need to be accounted for when posting.
I think the best solution is to make this a totally javascript entity. All I need to do is to be able to pass in the server side data. Calling JS from PHP does not work, although i have found many places where they show basically the same code , claiming that it works. think json needs a bit of tweaking to make this happen, but i'm not sure how to proceed.
View 3 Replies
View Related
Jul 23, 2005
I have a few values and variables that I want to post to a server
(without using a SUBMIT button). Is there a way to post data from
within javascript - do sockets or connections have to be open for this
to work?
View 5 Replies
View Related
Jul 14, 2010
I found this formwizard script example online but I don't know how to use the data with php for emailing and saving to database for example.The script attaches the result to <p id="data"></p> like this
firstname=&surname=&day=DD&month=MM&year=YYYY&lastFour=XXXX&countryPrefix=+358&areaCode=&phoneNumber=&email=jasonhoefie@hotmail.com&username=&password=&retypePassword=
Attachments
jquery-formwizard.zip
Size : 48.6 KB
Download : 422
View 4 Replies
View Related
Jul 22, 2010
I have a JQGRID table and when I click submit I wanna post entire grid data to server.
View 2 Replies
View Related
Nov 23, 2011
I am trying to build a table from backend data and then perform a filter on it using the picnet table filter. After much messing about I have discovered that the problem lies with the table data returned from the server. As a test, all I want to do is get jQuery to make an alert when a table cell is clicked. I added a hard coded table cell at the beginning of the table and when I clicked on it, the alert appeared. However, clicking on any other cell had no effect.
[Code]....
View 5 Replies
View Related
Mar 20, 2009
I am trying to read data from server using AJAX XMLHttpRequest.responseText.In received data, there are lot of similar type of characters which has tge value of FFFFFD (65533). I think, all characters which has the value above 127 are converted to default character.
View 1 Replies
View Related
Dec 10, 2009
Is it possible to create a script which exports data from a SQL server into MS Word?
View 4 Replies
View Related
Jun 10, 2010
I built a pretty simple Ajax request which needs to send some data to the server and put the resulting HTML in a div. Unforunately, I need to POST the data. I used .post() and it worked fine ... *on Chrome and Opera!* ... on Firefox no data gets posted even though firebug shows the data in it's console. I ended up building the longest possible request, just to try all the options. No luck. As soon as I POST anything, Firefox won't receive the data. If this was a Firefox issue, wouldn't I read about it everywhere? What's wrong?
View 2 Replies
View Related
Sep 4, 2010
I'm not sure how to make something draggable which is dynamically loaded. The click event works fine on the new content though.
Like for example [code]...
View 4 Replies
View Related
Jun 23, 2010
Wantto import data from excel to SQL server from a web page, but wonder whether it is possible to do it without uploading the excel file from client's machine to server first.
View 4 Replies
View Related
Feb 8, 2010
You can use JQuery's data method (e.g. $('#MyID').data('MyVar', 'MyValue');) to easily store/retrieve information.
However, I was wondering if it is possible for my PHP generated page to add HTML tags that initialize the JQuery's data method variables. Regularly, I want server side variables to be accessible client side. It would be very helpful if I could initialize data method variables during PHP page generation.
If this is not possible, are there any suggestions on how to efficiently communicate server side variables to client side?
View 3 Replies
View Related