473,395 Members | 1,608 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HTTP Request from JavaScript

Hi,
I am trying to create and send a HTTP Request from a .js file to my server. But when I do this using the GET method and send the necessary parameters along in the URL, i have a problem. That at times the URL length goes beyond 255 characters and the request is rejected.

Then I tried the same using the HTTP POST method and using the XmlHttpRequest.send() method. The problem here is that, this method is too slow and the browser hangs if i do this in synchronous mode (xmlhttprequest.open('POST', "../MainView", false)). But this behavior is not acceptable.

So can some one suggest me an alternative to send the HTTP request, in such a manner that I can also accommodate all my parameters and it is faster than XmlHttpRequest

TIA
Harmik
Feb 6 '07 #1
17 5417
acoder
16,027 Expert Mod 8TB
Welcome to The Scripts

Instead of using the synchronous method, use asynchronous (the A in AJAX). See this page for more info.
Feb 6 '07 #2
Welcome to The Scripts

Instead of using the synchronous method, use asynchronous (the A in AJAX). See this page for more info.
Thanks a lot for your response. But the problem here is that I need to send the HTTP Request synchronously.

So what I would appreciate is an alternative method to send the request ...

TIA
Harmik
Feb 6 '07 #3
acoder
16,027 Expert Mod 8TB
Is there any particular reason why you must send it synchronously? It is unreliable performance-wise and unfriendly usability-wise, and can cause the browser to hang as you're experiencing.
Feb 6 '07 #4
Is there any particular reason why you must send it synchronously? It is unreliable performance-wise and unfriendly usability-wise, and can cause the browser to hang as you're experiencing.
The reason for this is that I'm using this request to delete some records from a grid in the UI. So i can't show any status to the user (for the delete operation) till I get a response back. Do u have any suggestions on this.

Also is it true that HTTP1.1 supports unlimited character length in the URL's (and not limited to 255 characters)

Regards
Harmik
Feb 6 '07 #5
steven
143 100+
The reason for this is that I'm using this request to delete some records from a grid in the UI. So i can't show any status to the user (for the delete operation) till I get a response back. Do u have any suggestions on this.

Also is it true that HTTP1.1 supports unlimited character length in the URL's (and not limited to 255 characters)

Regards
Harmik
That's exactly what Asynchronous operations are for. Do the work in the background, then dynamically display the status / changes, once the operation has completed, without reloading the page. If you think it will take some time for the operation to complete, you can display a small "working" animation, like a loading bar, or a spinning loading animations, then once the operation is complete, remove the animation and make the changes on the page. This way, the user isn't waiting on that result, they can also do other things on the page, whilst they're waiting.
Feb 6 '07 #6
acoder
16,027 Expert Mod 8TB
You can still do it asynchronously. Just use the onreadystatechange to check the status. When its complete, it will be set to 4. See here for more details.
Feb 6 '07 #7
acoder
16,027 Expert Mod 8TB
That's exactly what Asynchronous operations are for. Do the work in the background, then dynamically display the status / changes, once the operation has completed, without reloading the page. If you think it will take some time for the operation to complete, you can display a small "working" animation, like a loading bar, or a spinning loading animations, then once the operation is complete, remove the animation and make the changes on the page. This way, the user isn't waiting on that result, they can also do other things on the page, whilst they're waiting.
Yes, Steven, good explanation.
Feb 6 '07 #8
Yes, Steven, good explanation.
Thanks a lot guys ... for all the help and guidance ...

Cheers
Harmik
Feb 6 '07 #9
acoder
16,027 Expert Mod 8TB
You're welcome.
Feb 6 '07 #10
pankajit09
296 100+
That's exactly what Asynchronous operations are for. Do the work in the background, then dynamically display the status / changes, once the operation has completed, without reloading the page. If you think it will take some time for the operation to complete, you can display a small "working" animation, like a loading bar, or a spinning loading animations, then once the operation is complete, remove the animation and make the changes on the page. This way, the user isn't waiting on that result, they can also do other things on the page, whilst they're waiting.

Can anyone give me a sample code for loading animation and then unloading?
Dec 31 '07 #11
acoder
16,027 Expert Mod 8TB
Can anyone give me a sample code for loading animation and then unloading?
One way is to have a hidden div (visibility:hidden) which already contains the image. When you make the Ajax request, set it to visible.
Dec 31 '07 #12
pankajit09
296 100+
One way is to have a hidden div (visibility:hidden) which already contains the image. When you make the Ajax request, set it to visible.

How to load the animation for Synchronous Ajax request?
Jan 4 '08 #13
acoder
16,027 Expert Mod 8TB
How to load the animation for Synchronous Ajax request?
The same, but the animation may not run properly because with a synchronous request, the browser waits for the response. Why use a synchronous request anyway? It's better to just refresh the page instead.
Jan 4 '08 #14
pankajit09
296 100+
The same, but the animation may not run properly because with a synchronous request, the browser waits for the response. Why use a synchronous request anyway? It's better to just refresh the page instead.
Actually I want to freeze the background while the Ajax is going on and also showing a GIF image(progress) .

How to do that ?
Jan 4 '08 #15
acoder
16,027 Expert Mod 8TB
Actually I want to freeze the background while the Ajax is going on and also showing a GIF image(progress) .

How to do that ?
With a synchronous request, the browser will freeze, so your animated image will show, but it may not be animated! Show the image before you make the request and possibly some text to explain what's happening. I think a non-Ajax solution makes more sense here, but that's just my opinion.
Jan 4 '08 #16
pankajit09
296 100+
With a synchronous request, the browser will freeze, so your animated image will show, but it may not be animated! Show the image before you make the request and possibly some text to explain what's happening. I think a non-Ajax solution makes more sense here, but that's just my opinion.

I am saving the data present in cells of a spreadsheet so I think non Ajax is not good.
What do you think ?
Jan 5 '08 #17
acoder
16,027 Expert Mod 8TB
I am saving the data present in cells of a spreadsheet so I think non Ajax is not good.
What do you think ?
The only reason why I think it's better not to use 'Ajax' here is that you're planning to use a synchronous request. This freezes the browser until a response is received which goes against the whole concept of Ajax. Why not use an asynchronous request? Does it take a long time for the server-side script to be processed?
Jan 5 '08 #18

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Michael Foord | last post by:
#!/usr/bin/python -u # 15-09-04 # v1.0.0 # auth_example.py # A simple script manually demonstrating basic authentication. # Copyright Michael Foord # Free to use, modify and relicense. #...
1
by: Matt | last post by:
My problem is when the user click the submit button, it will launch another new window for the request page. I want to confirm we cannot use JavaScript open window functions to open a request page?...
3
by: reneeccwest | last post by:
How can I simulate HTTP post request by JavaScript? When I select from <SELECT> combo box. onClick will call JavaScript function. I want this function to send HTTP POST request with the selected...
3
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
3
by: superseed | last post by:
Hi, I'm currently coding in C# a class to control a PTZ (Pan Tilt Zoom) Camera. To control the camera I have to send request on a CGI on it. Something like this : ...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
11
by: Steve Kirkendall | last post by:
I need a work-around for an IE limitation, regarding fetching HTTP documents in the background. It takes a bit of explaining; please be patient... I'm working on an project that will run on an...
2
by: Centaury | last post by:
Hello, some time ago I've created a site in asp in combination with the XML http request object, this way I was able to load content from a database into div elements, this way there is no need to...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Make CStr for JavaScript on ASP w/ Request.Form and QueryString In ASP, Request.Form and Request.QueryString return objects that do not support "toString", or any JavaScript string...
7
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I am trying to set this up using asp code and IIS configuration. But it seems not working. Here it is the way I am doing. In IIS I set up a virtual directory with secure communication, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.