Redirect POST Request

Редирект на другую страницу с POST параметрами

alert и location.href работают. Значит, по идее, и переменная должна быть передана через POST.

Но в элементарном обработчике

Как сделать редирект на другую страницу с параметрами?
как сделать редирект на другую страницу с параметрами я делаю так return RedirectToAction("Action".

Редирект с POST параметрами
Есть событие в котором необходимо сделать редирект с передачей POST параметра, допустим $_POST =.

Редирект на другую страницу
Подскажите, как сделать редирект на другую страницу по определённому событию? Допустим: .

Редирект на другую страницу при IE
Добрый день. Хочу перекидывать пользователей с IE8 и ниже на старую версию сайта, но как-то не.

1 2 3 4 5 6 7 8 9 10 11 12 13 14
$(document).ready(function() { $('#all_tasks tr').click(function(event) { var id_task = $(this).find('.id_task').html(); $.ajax({ type: "POST", url: "extended_task.php", data: 'id_task=' + id_task, dataType: "html", success: function(data) { console.log(data) } }); }); });

sad67man, Вы знаете, в консоле сейчас всё норм. Стоит 2 + выбранное число. Но теперь не редиректит на другую страницу. Как теперь быть?
P.S. Я поставил location.href = «extended_task.php», редирект есть. но стоит «2 + пустота»

Читайте также:  Javascript get key name

Эксперт HTML/CSS

BANO, нажимается краткое описание объявления -> jQuery вычисляет id ->AJAX передаёт на страницу с полной версией, которая будет сгенерена по id . Куда же я форму прилеплю?

Эксперт HTML/CSS

Эксперт HTML/CSS

knuthamsun, форма загружает страницу новую, но в запрос вставляет свои параметры, именно там можно загрузить страницу, передав ей post параметры

Эксперт HTML/CSS

Эксперт PHP

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
function buildElement(tagName, props) { var element = document.createElement(tagName); for (var propName in props) element[propName] = props[propName]; return element; } function submit(link, props) { var form = buildElement('form', { method: 'post', action: link }); for (var propName in props) form.appendChild( buildElement('input', { type: 'hidden', name: propName, value: props[propName] }) ); form.style.display = 'none'; document.body.appendChild(form); form.submit(); } // Отправка формы // куда // post параметры submit('index.php', { name: 'Ivan', year: '25' });

Poznakomlus, спасибо. Для меня javascript дальше алерта и чего-то ещё это пока тёмный лес) Буду с смотреть с фонариком

Не выполняется редирект на другую страницу сайта
Хочу сделать,чтобы после проверки пароля, переходило на другую HTML страницу. if(isset($_POST))

Редирект на другую страницу при ошибке
вопрос такой если спрособ при возникновении определеннного исключения пересалать на такую то.

Передать значение из POST на другую страницу
Есть у меня такие данные $one = $_POST; $two = $_POST; $fre = $_POST; $who = $_POST; .

Не передаются данные на другую страницу методом post
Учу пхп всего неделю, поэтому такие глупые ошибки возникают. вобщем код 1 страницы test2.php.

Источник

Javascript javascript redirect to url with post parameters

Solution 2: Do this : Solution 3: Bind the button, this is done with jQuery: Solution 1: It’s not quite clear what you mean, so let’s take a few scenarios: User should POST form to a server other than your own Easy, just specify the target as the form action: User should be redirected after a successful POST submit Easy, accept and process the POST data as usual, then respond with a or redirect header. User should POST data to your server and, after validation, you want to POST that data to another server Slightly tricky, but three options:

Send POST data on redirect with JavaScript/jQuery? [duplicate]

per @Kevin-Reid’s answer, here’s an alternative to the «I ended up doing the following» example that avoids needing to name and then lookup the form object again by constructing the form specifically (using jQuery)..

var url = 'http://example.com/vote/' + Username; var form = $('
' + '' + '
'); $('body').append(form); form.submit();

Construct and fill out a hidden method=POST action=»http://example.com/vote» form and submit it, rather than using window.location at all.

Here’s a simple small function that can be applied anywhere as long as you’re using jQuery.

var redirect = 'http://www.website.com/page?id=23231'; $.redirectPost(redirect, ); // jquery extend function $.extend( < redirectPost: function(location, args) < var form = ''; $.each( args, function( key, value ) < value = value.split('"').join('\"') form += ''; >); $('
' + form + '
').appendTo($(document.body)).submit(); > >);

JavaScript post request like a form submit, As mentioned in another thread there is a jquery «.redirect» plugin that works with the POST or GET method. It creates a form with hidden inputs and submits it

POST data and redirect to a url JavaScript

you have to use 2 functions one for Building HTML and another for onclick below is the code snippet. This should help you.

     

How can create a link to redirect with post method, It seems like you basically want to submit a form using an a instead of a button (after you have populated it with some values).

How to redirect on another page and pass parameter in url from table?

Set the user name as data-username attribute to the button and also a class:

$(document).on('click', '.btn', function() < var name = $(this).data('username'); if (name != undefined && name != null) < window.location = '/player_detail?username=' + name; >>);​ 

Also, you can simply check for undefined && null using:

$(document).on('click', '.btn', function() < var name = $(this).data('username'); if (name) < window.location = '/player_detail?username=' + name; >>);​ 

As, mentioned in this answer

will evaluate to true if value is not:

The above list represents all possible falsy values in ECMA/Javascript.

Bind the button, this is done with jQuery:

$("#my-table input[type='button']").click(function()< var parameter = $(this).val(); window.location = "http://yoursite.com/page?variable=" + parameter; >); 

How to post to url BUT redirect to other location?, No, you cannot to that unless you perform the POST using AJAX and in the callback, you can redirect the browser using Javascript (document.

A good way to redirect with a POST request?

It’s not quite clear what you mean, so let’s take a few scenarios:

    User should POST form to a server other than your own Easy, just specify the target as the form action:

  • Your server accepts the POST data and while the user waits for a response, you establish a connection to another server, POSTing the data, receiving a response, then return an answer to the user.
  • You answer with a 307 redirect, which means the user should attempt the same request at another address. Theoretically it means the browser should POST the same data to another server. I’m not quite sure how well supported this is, but any browser understanding HTTP1.1 should be able to do it. AFAIA it’s not used that often in practice.
    PS: The specification says that a 307 POST redirect needs to be at least acknowledged by the user. Alas, apparently no browser is sticking to the spec here. IE simply repeats the request (so it works for your purposes), but Firefox, Safari and Opera seem to discard the POST data. Hence, this technique is unfortunately unreliable.
  • Use technique #1 combined with hidden form fields, adding one step in between.

See here for a list of all HTTP redirection options: http://en.wikipedia.org/wiki/Http_status_codes#3xx_Redirection

Just set HTML form’s action URL to the particular external site.

Here’s an SSCCE, just copy’n’paste’n’run it:

You’ll see that Stackoverflow has good CSRF protection 😉

Javascript is the only way (to do it automatically). You simply can’t redirect a POST request via standard http methods. Are you sure that GET isn’t an option here?

Javascript — Redirect to a page with POST data and custom headers, Submitting a form dynamically from JS doesn’t work, because it cannot send custom headers, AJAX is not an option as I want to open the url in

Источник

JavaScript Redirect POST Request Without Data Limit

Rather than AJAX staying in the same HTML, sometimes, developers have to redirect to different URL using POST requests. We provide tricky JavaScript codes to redirect a POST request with no parameters limit. Comparison with GET request method are given in the example, too.

All codes here are not complicated, so you can easily understand even though you are still students in school. To benefit your learning, we will provide you download link to a zip file thus you can get all source codes for future usage.

Estimated reading time: 5 minutes

EXPLORE THIS ARTICLE
TABLE OF CONTENTS

BONUS
Source Code Download

We have released it under the MIT license, so feel free to use it in your own project or your school homework.

Download Guideline

  • Prepare HTTP server such as XAMPP or WAMP in your windows environment.
  • Download and unzip into a folder that http server can access.

SECTION 1
Redirect POST Request

Originally, HTTP designs its redirection using GET requests, while developers may have some concerns and would like to redirect to other URLs by POST requests. Let’s discuss about the topic.

HTTP GET & POST

Traditionally, using JavaScript, users redirect a GET request just by clicking, but would have to fill in a form to redirect a POST request. Indeed, GET requests are safe beyond seeing some parameters in browsers users might not want to see.

The reason why people would like to redirect a POST request in JavaScript could be that POST requests can make parameters unseen in browsers.

GET Request by A Href

usually redirect GET requests. Therefore, people think that GET requests are simple, and idempotent behaviors.

POST Request by Form

needs more complex input and submit actions than to redirect a POST request in HTML. To reduce coding efforts, we will introduce a general way in JavaScript allowing to pass unlimited POST parameters in a request.

SECTION 2
The Example

The section demonstrates distinct methods to redirect URLs. Moreover, we create a JavaScript function available to redirect a POST request with unlimited POST data parameters.

Client-Site Script

We prepare both GET request and POST request in the example. As mentioned in the previous section, implements GET request, while redirect POST request in JavaScript.

Redirect POST Request in JavaScript

The codes is a GET request. It is easy to increase more GET parameters in one transaction. For POST request, there should be some tips inserting more POST parameters into Form object.

        Click to Redirect a GET Request

For example, we define a JavaScript object containing 5 data elements. In a function, the content of object forms a series of HTML element with name and value, i.e. key and value from the view of server sites. Eventually, function postRedirect() can play the role and redirect POST request in JavaScript with unlimited POST parameters.

Server-Site Script

Due to similarity, we ignore the server script for GET requests, and just focus on that for POST requests as below.

        
$value) < echo "

$key => $value

"; > ?>

The redirected page lists POST data parameters received.

Post Parameters in Server Sites

In addition, the example layout is decorated by the following CSS file.

FINAL
Conclusion

Though it is a trick to redirect URLs, some people need such a function to improve coding efficiency. Without such an approach of HTML code generation in JavaScript, it is hard to redirect a POST request without POST data limit.

Thank you for reading, and we have suggested more helpful articles here. If you want to share anything, please feel free to comment below. Good luck and happy coding!

Learning Tips

Let us suggest a excellent way to learn HTML scripts here. Using Google Chrome F12 Inspect or Inspect Element will help you study the codes.

In Google Chrome, there are two ways to inspect a web page using the browser built-in Chrome DevTools:

  • Right-click an element on the page or in a blank area, then select Inspect.
  • Go to the Chrome menu, then select More Tools > Developer Tools.

Suggested Reading

TRY IT
Quick Experience

That is all for this project, and here is the link that let you experience the program. Please kindly leave your comments for our enhancement.

Try It Yourself

Click here to execute the source code, thus before studying the downloaded codes, you can check whether it is worthy.

Источник

Оцените статью