Local project simulated cross-domain requests

The browser just open a Web site, F12 to open the console

2. Enter the code input request

.ajax $ ({
URL: "HTTP: // localhost: 8080 / SYS / topHotNews / Update", the transmission path //
type: "post", // mode transmitted
data: '{ "newsId": "5" , "type": "1" , "operation": "1"} ', // data transmitted
contentType: "application / json", // submit data type
dataType: "json", // the data type returned by the server
success: function (Data) {
IF (data.msg = "success") {
Alert ( "submitted successfully");

} the else {
Alert ( "Commit failed");
}
},
error: function (Data) {
Alert ( "Commit failed");
}

});

 

3. Background receiver interface parameters manner

@RequestMapping(value="/update",produces = "application/json;charset=utf-8", method = RequestMethod.POST)
@ResponseBody
public String insert(@RequestBody Test test){
    //处理逻辑代码 
}

4. The net effect

 

Guess you like

Origin www.cnblogs.com/L237/p/12556488.html