Home > Back-end >  The ajax request, not an error but can't get into the controller method
The ajax request, not an error but can't get into the controller method

Time:09-22


/* *
* message authentication code
* @ type {string}
*/
Var SMS="";
$(" # "BTN). Click (function () {
Var phone=$(" # phone "). Val ();
If (phone! {
="")$. Ajax ({
Type: "GET",
URL: "/smscode sendsms/logged",//send the request admin/core/arm/controller \ SmsCodeController system/core/arm/controller/sendsms
DataType: "json",
Data: {
SmsType: "1004",
Phone: phone
},
Success: the function (data) {
SMS=data;
}
});
} else {
Alert (" please enter the phone number ");
return false;
}
});
$(" # lo "). Click (function () {
Var code=$(" # code "). Val ();
If (code=="") {
Alert (" please enter the verification code ");
} else {
If (SMS==code) {
Window. The location. Href="https://bbs.csdn.net/topics/success.jsp";
} else {
Alert (" verification code error ");
}
;
}
;
});

});


A simple text message validation of ajax, but after I set breakpoints to the first arrow directly to the second arrow, just skip the middle excuse me where is the problem

CodePudding user response:

Controller over there and see what has to print, look at the controller code

CodePudding user response:

The browser console, may not support the get method

CodePudding user response:

reference 1st floor like a dog. The man. Response:
controller over there and see what has to print, look at the controller code

What also have no

@ Controller
@ RequestMapping ("/smscode ")
Public class SmsCodeController extends BaseController {
@ the Resource (name="smsCodeService")
Private SmsCodeService SmsCodeService;
@ RequestMapping (value="https://bbs.csdn.net/sendsms/logged", produces=MediaType. APPLICATION_JSON_UTF8_VALUE)
@ ResponseBody
Public Object sendSms () throws the Exception {
Dto PDto=super. GetParamAsDto ();
ResponseDto ResponseDto=super. NewResponseDto ();
SmsCodeService. SendMsg (responseDto, pDto getAsInteger (" smsType "), pDto. GetAsString (" receiver "), pDto);
Return super. Write (responseDto, null);
}
}

CodePudding user response:

refer to the second floor el alamein regretless reply:
the browser console, may not support the get method


The zha to see, what also have no

CodePudding user response:

Ajax with a post request

CodePudding user response:

reference 5 floor like a dog. The man. Response:
ajax use a post request


How to write a post request I url

CodePudding user response:

unknown sleep and complete reference 6 floor silly response:
Quote: refer to 5 floor like a dog. The man. Response:

Ajax use a post request


Post requests me how to write the url

Url: why do you want to change the type: "GET", change the type: "post", is not it

CodePudding user response:

reference 7 floor like a dog. The man. Response:
Quote: refer to the sixth floor of unknown sleep and complete silly response:

Quote: refer to 5 floor like a dog. The man. Response:

Ajax use a post request


Post requests me how to write the url

Url: why do you want to change the type: "GET", change the type: "post", not just good


Because no tried I just started to use is the POST

CodePudding user response:

There is something wrong with the request URL, lack of the http://in front of the... Or https://...

CodePudding user response:

F12 look at the situation of the Network request, was written by 40 x is ajax has a problem, is the 50 x is the controller has a problem

CodePudding user response:

Morning, 9/f,
reference under smile response:
request URL has a problem, the lack of the http://in front of the... Or https://...

 $. Ajax ({
Type: "POST",
URL: "/smscode sendsms/logged",//send the request admin/core/arm/controller \ SmsCodeController system/core/arm/controller/sendsms
DataType: "json",
Data: {
SmsType: "1004",
Phone: phone
},

CodePudding user response:

references to the tenth floor potato is my favorite response:
F12 look at the situation of the Network request, was written by 40 x is ajax has a problem, is 50 x is there is something wrong with the controller

CodePudding user response:

Quote: unknown sleep and complete reference to 12 floor silly response:

Request not issued, the console how can no errors

CodePudding user response:

potato is my favorite Quote 13 floor response:
Quote: unknown sleep and complete reference to 12 floor silly response:

Request not issued, the console can no error about it


So I don't understand very much, have rich my head hurts

CodePudding user response:

Have any interceptors, if it is a new interface, it is intercepted

CodePudding user response:

unknown sleep and complete reference 14 floor silly response:
Quote: refer to the 13th floor potato is my favorite response:

nullnullnullnullnullnullnullnullnull
  • Related