Home > front end >  Ask, after the success of the ajax implementation, success inside how to execute an SQL update state
Ask, after the success of the ajax implementation, success inside how to execute an SQL update state

Time:11-27

Call interface, the local database information uploaded to the interface, the call is completed, the state of the record to local database updates for uploaded, to ask how to operate, thank you,
The following update statement, there is a problem, as long as a open this upload page, there is no point to upload button, the update statement is executed, excuse me what reason is this?

 $. Ajax ({
Type: "POST",
DataType: "text",
Url: "https://www.baidu.com/ProjectService.asmx/CreateProject",
Data: {" jsonStr ": jsontr},
CrossDomain: true==! (document. All),//ie 10 browser need to add the below!!
Success: the function () {
Alert (" uploaded successfully, please check whether there is upload record!" );
<%
SQL="update [project] set status='uploaded where id=" & amp; Request (" id ")
Conn. Execute (SQL)
% & gt;
},
Error: function () {
Alert (" upload fails, please contact the administrator to confirm!" );
}
});

CodePudding user response:

This is how complex ah. Suggest you see Promise. You can write like this:
 f1 (). Then (f2); 
f1, remote update function f2 said local update function

CodePudding user response:

ABC: an introduction to Promise Promise object. If you have a look at the jquery documentation, document has introduced: deferred. Promise ()

CodePudding user response:

jsp? With new write in service, call him here method

CodePudding user response:

Default is asynchronous ajax requests, set the ajax async is false, the method of parameter update success function returns success in SQL statements

CodePudding user response:

 (f1). Then (f2); 

CodePudding user response:

<%
SQL="update [project] set status='uploaded where id=" & amp; Request (" id ")
Conn. Execute (SQL)
% & gt;
This code is Java code, even though you are on the success, but a into the JSP page, it is the immediate execution of a painting, you should be performed after the success, then call an ajax method, in this method, the ajax request url, to carry out your this piece of Java code, the url may be a servlet or JSP

CodePudding user response:

Add an ajax request inside success, then write code executing SQL statements
  •  Tags:  
  • Ajax