mgalante / jquery.redirect Goto Github PK
View Code? Open in Web Editor NEWjQuery Redirect Plugin
jQuery Redirect Plugin
The following doesn't open in a new tab/window as it should.
$.redirect(url, { "enquiryText": message }, "POST", "_blank");
This plug is working fine for me except one scenario. I am having one parameter with name submit. when i am using this plug in whit that parameter it is creating a hidden element as name="submit"
So my form is not submitting due to this.
Can anyone help me out.
Hi!
First of all, I'd thank you for creating this useful software! Could you please also consider adding a kind of license header to clarify the conditions under which we can use of it? Is it distributed under the same license as jQuery itself (namely https://jquery.org/license/)?
I understand that this sounds a bit bureaucratic, but is really important for those who'll try to make a us of.
Thank you very much!
Valentin
it adds hash to the value of the last key
How can I do this?
$.redirect("{% url "/login.php", {'id[]': [1, 2]}, 'GET');
can I transfer an object only?
Supposing that you submit your form using a target='_blank' attribute, i think it's a good idea to remove the form from the DOM, cause i've made some tests and it create a new form for each $.redirect call.
For instance:
#38
Hello,
First, thank you for providing this very unknown and useful library.
I am trying to add headers for CSRF security to the system I'm developing. I found that adding global headers to the jQuery Ajax requests is possible through $.ajaxSetup().
Do you think there is a way to add headers to the $.redirect() calls (only POST requests)? Maybe modifying the code of the library a little. Or should I add them manually to every call of the redirect library?
Thanks
Edit: The CSRF fields can also be parameters of the request and not request headers.
Hi I'm experimenting a strange behavior, during the form submit if a parameter is named for example "test" the script change his name to "0[test]".
Is this normal?
method.toUpperCase is not a function
I am using this library to redirect from a page to another one, which work like a charm. But we wanted to host this page in an iframe, and when we do that the redirection happens on the iframe level only and not the parent window. Is there a way to force parent page redirection in a clean way using this library.
Estoy agregando un headers con un token:
var csrfToken = <?php echo json_encode($this->request->getParam('_csrfToken')); ?>;
$.redirect('<?php echo Router::url(["controller" => "Users", "action" => "previo"]); ?>', {headers: {'X-CSRF-Token': csrfToken}} ,{filtro : 'Cliente'});
Pero me muestra el error: "TypeError: method.toUpperCase is not a function" en esta línea del jquery.redirect:
$.redirect = function (url, values, method, target, traditional) { method = (method && ["GET", "POST", "PUT", "DELETE"].indexOf(method.toUpperCase()) !== -1) ? method.toUpperCase() : 'POST';
Otherwise bower doesn't understand your updates
Hi, I am trying to use this Lib in a react project, but I can not get it working. Do you have an Idea how I can go about it?
how i want to double url ??
May I send headers' data ?
$.redirect('/auth/home', {headers: createAuthorizationTokenHeader()});
function createAuthorizationTokenHeader() {
var token = getJwtToken();
if (token) {
return {"Ok": "Bearer " + token};
} else {
return {};
}
}
Hello,
I am using redirect.js and send this request:
$.redirect('details.php', {'return': 'yes'}, 'post');
but i am getting error of $.redirect is not a function
Hi All,
Target _self doesn't work. I don't see any issue in console.
With _blank target is working.
`$(document).ready(function(){
$('#userlogin').submit(function(){
var captcha = $('#captcha').val();
var randomcaptcha = '<?php echo $captcha; ?>';
if(captcha == randomcaptcha){
var username = $('#username').val();
var password = $('#password').val();
$.redirect("<?php echo URL ?>login/check", {username , password}, "POST");
}else{
$.redirect("<?php echo URL ?>login/wrong", {username , password}, "POST");
};
});
});`
I'd like to modify one or more of the inputs before submitting the form. It would be helpful to have a transformation hook to accomplish this. Say, something like:
$.redirect(url, data, function(name, value) {
// Transform and return value.
});
Is there a better way to do this?
I am sending AJAX POST request from the page and redirecting to another page on the same domain.
$.ajax({
type: form.method,
url: form.action,
data: $(form).serialize(),
dataType: 'json',
success: function(response) {
// redirect with response
$.redirect({
url: <my_url_here>,
values: { payload: response },
target: '_blank'
})
}
})
How can I access payload
from the redirected page?
When I load a page in IE11 that uses jquery.redirect.js I get this error:
Script from https://raw.githubusercontent.com/mgalante/jquery.redirect/master/jquery.redirect.js was blocked due to mime type mismatch
Have you seen this before or know of a fix?
hello, I'm having trouble opening a new tab with this code.
function open(){
$.redirect(
"http://posttestserver.com/post.php",
{
user: "johnDoe",
password: "12345",
submit: "name"
},
"POST",
"_blank"
);
}
What can it be ?
Hi, Can I Post Json Data?
var data = '{keys:' + JSON.stringify(selectedKeys) + '}';
Uncaught TypeError: Cannot set properties of undefined (setting 'redirect')
Hello
I'm using your code and it's great !.
but when i send Object that contains UTF-8 words(like persian words) , params isn't sent properly because in content type we don't have charset="utf-8" .
do you have any solution ?
thank you ;D.
Any fields that have a blank string as a value are removed. This does not match $.ajax()
For example $.ajax() would send:
foo[bar]: beep
foo[test]:
foo[bla]: boop
but $.redirect() sends:
foo[bar]: beep
foo[bla]: boop
Hello,
I think I may have discovered a bug.
I have this object, which I've encoded as JSON.
{
"survey":{
"questions":[
{
"editUrl":"/survey/partials/textQuestion",
"isEditing":false,
"name":"test"
}
],
"configurationId":"FAA2A792-5EF9-4736-9AD1-FD30A587945E"
}
}
When this is POSTed, it looks like the keys in the questions array are being put split into arrays. Here is what I get when I run var_dump() on the "survey" object that's posted.
Array
(
[questions] => Array
(
[0] => Array
(
[editUrl] => /survey/partials/textQuestion
)
[1] => Array
(
[isEditing] => false
)
[2] => Array
(
[name] => test
)
)
[configurationId] => FAA2A792-5EF9-4736-9AD1-FD30A587945E
)
I expected "editUrl", "isEditing", and "name" to keys in the "questions" array, but they are encoded differently, which I think is a bug.
Hope this helps, and thanks for the library :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.