"POST" request to server using code below
however do not sending param data to server.
I tried jQuery Way and
var request = $.ajax({
url: baseUrl,
type:'post',
data: 'userId=userabcd&passwd=abcd1234',
});
request.done(function( msg ) {
console.log(msg);
});
request.fail(function( jqXHR, textStatus ) {
alert( "Request failed: " + textStatus );
});
AngularJS Way.
$http({
method : 'POST',
url : baseUrl,
headers : { 'Content-Type': 'application/x-www-form-urlencoded' },
data : 'userId=userabcd&passwd=abcd1234'
}).success(function(data, status, headers, config) {
console.log(data);
console.log(status);
console.log(headers);
console.log(config);
}).error(function(data, status, headers, config) {
console.log(data);
// called asynchronously if an error occurs
// or server returns response with an error status.
});
but both are not sending "POST" query to server.
what am i doing wrong
please help.
server information
Mircrosoft/IIS8.0, ASP
Without seeing your server-side code it is difficult to say if that is a problem. The JS you have presented generally looks okay. You say that it runs without errors but fails to produce the expected results on the server. So I suggest you add the server-side code.
Both cases accept data
as an object rather that a string which is generally more convenient. (avoids having to deal with encoding characters yourself)
For example:
data: {userId:'userabcd', passwd:'abcd1234'},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.