ajax success but not sending post data
Date : March 29 2020, 07:55 AM
may help you . Your datastring should contain data encoded as application/x-www-form-urlencoded e.g.: var datastring="foo=123";
|
Getting ajax post data on success
Tag : php , By : SilverRuby
Date : March 29 2020, 07:55 AM
I hope this helps . Well, if you're posting, you should use the jquery post function here$.post(
url,
{lan_setting:"en"},
function( data, status, jqXhr ){
alert(data.lan_setting);
},
"json"
);
<?php
// do stuff
$response = new stdClass;
$response->lan_setting = $_POST["lan_setting"];
print json_encode($response);
?>
|
Ajax, post data but not callback success
Date : March 29 2020, 07:55 AM
I think the issue was by ths following , Yes I know there is so many question like mine, I looked all questions and answers but The solutions is given didn't help me. /* Change few of your lines: */
<button id="loginButton" type="submit" class="btn btn-success pull-right" onclick="login(event)">Giriş</button>
AND
function login (e)
{
e.preventDefault();
var Name = $("#userName").val();
var Pssword = $("#userPassword").val();
...
and further remains same.
|
ajax on success post form and change page
Date : March 29 2020, 07:55 AM
like below fixes the issue I have to admit, i'm a bit unclear still on the first part of what is happening during your submission, however, you could add yourself to the onsubmit function to first send the data to your ajax-target, and after you have completed the request (succesfully) redirect the user to the second page. // be sure to always return false, otherwise the default method would be used
function postForm(formElement) {
if (typeof formElement === 'undefined' || !formElement) {
// invalid call (expects at least the form element)
return false;
}
// you could do some validation here, if you want, if it's unsuccesfull, show a message and return false
// ...
// check if the request hasn't been sent yet, if so, return false won't be resubmitted
if (postForm.active) {
return false;
}
postForm.active = true;
// add a default option for the ajax call (in case no js is available, this option wouldn't be there
// so you could redirect the page from aspx page)
var data = {
ajax: 1
},
hiddenElements = $('[type=hidden]'),
i,
len,
dataKey,
dataValue,
dataItem,
targetUrl = formElement.getAttribute('data-redirect');
// get the hidden values to send that were added to the form
for (i = 0, len = hiddenElements.length; i < len; i++) {
dataItem = hiddenElements[i];
dataKey = dataItem.name;
dataValue = dataItem.value;
if (typeof data[dataKey] !== 'undefined') {
data[dataKey] = ',' + dataValue;
} else {
data[dataKey] = dataValue;
}
}
// send the ajax request
$.ajax({
url: formElement.action,
type: formElement.method || 'post',
data: data,
complete: function(response, state) {
// free the form again (can be resubmitted at this time)
postForm.active = false;
if (state !== 'error') {
// success, navigate to defined data-redirect
window.location.assign(targetUrl);
} else {
// failed throw error, show message to user
alert('Error occured during the request: ' + state);
}
},
});
// return false so that the form doesn't submit on its own
return false;
}
// attach to all css class with name .submitter (allowing you to attach the mock submit request site wide)
$(function() {
$('.submitter').on('click', function(e) {
e.preventDefault();
$('#mok').submit();
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form action="[send-ajax-data-target-url]" method="post" id="mok" onsubmit="return postForm(this);" data-redirect="Confirmation.aspx">
<input id="mail" type="hidden" value="data" name="m" />
<button type="submit">Mock request</button>
</form>
<a href="#" class="submitter">Mock request</a>
|
Ajax POST Success But No Data Are Send
Tag : jquery , By : Nandor Devai
Date : March 29 2020, 07:55 AM
will help you I have problem to upload multi file using ajax, in this case im using codeingiter, when I call $_POST array return null on upload function, this is my my form I'm using this snippets , Try with $_FILES public function test_upload()
{
echo "<pre>";
print_r ($_FILES);
echo "</pre>";
}
<input type="file" name="files[]" multiple />
|