[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do i pass headers when specifying a location with window.location.href

Posted on 2016-08-15
5
Medium Priority
?
1,952 Views
Last Modified: 2016-09-06
HI,
Currently i am on a html page which has an submit button. And when that button is clicked the user goes to the url :
url?validation=...& etc
This is achived by setting a on click listener on submit button and executing :
window.location.href =url?validation=...
How do i achive the same if i want to pass this validation in the headers... Is there any way i can specify headers with window.location.href ??
OR any alternative way to achive the same using javascript etc.


Thanks
0
Comment
Question by:Rohit Bajaj
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 9

Assisted Solution

by:James Bilous
James Bilous earned 600 total points
ID: 41756807
Why don't you just submit the form using a post, no javascript required.
0
 
LVL 59

Accepted Solution

by:
Julian Hansen earned 1400 total points
ID: 41756830
What do you mean by headers? Are you referring to the form variables on the page.

It is possible to do this. You could use JQuery - something like this

<script src="http://code.jquery.com/jquery.js"></script>
<script>
$(function() {
    $('form').submit(function(e) {
      window.location.href = url + '?' + $(this).serialize();
      return false;
    });
});
</script>

Open in new window

If you mean in the actual headers then I don't think you can do that with windows.location as the request is being made by the browser.

You can modify the headers with an AJAX call.

Can you give us more information about the use case - what is it you are trying to achieve.
1
 

Author Comment

by:Rohit Bajaj
ID: 41757230
i mean the actual headers. the way we specify headers in an ajax call. but i think ajax call wont transfer me to another page it will just take a request and will get the response in the callback.
my aim is to actually to transfer the user to another page. but the validationID etc fields dont seem right in the query parameters logically.   Although i do achieve what i want to achieve using location.href ... that is transfer the user to other page and i embed this validationId in the resulting page
0
 
LVL 9

Assisted Solution

by:James Bilous
James Bilous earned 600 total points
ID: 41757383
Why don't you either A) Redirect upon successful completion of the ajax call or B) set the form method as post and submit it using a submit button. Why are you using window.location - what you are trying to do is the default behavior of a form with no javascript.
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 41757410
Can you give me an example of how you would do this with AJAX - just want to make sure I understand exactly what you are asking.

Why do you need to embed information in the header - there is scope for this in some applications but the usual method of data transfer is in the URL (parameters retrieved with a GET) or as POST data. Why specifically do you need to modify the headers
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
When it comes to security, close monitoring is a must. According to WhiteHat Security annual report, a substantial number of all web applications are vulnerable always. Monitis offers a new product - fully-featured Website security monitoring and pr…
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question