[WebMethod] public static string ABC(string ABC) { return ABC; }
Must be declared as static methods, and they must be annotated with the [WebMethod] attribute. But in webservice, it does not have to be a static method. Its objects can be list, dataset, class objects, etc... Next, you should consider how to let the client control in the foreground call the method in the background. This is when jqury comes on the scene. Alright.. Introduce jquery class library into the page
That’s it! Many things are done for us by the jquery class library. What we discuss here is how to use it and how to implement it. We don’t care! There are many things like $ in jquery Methods such as .ajax are provided for us to use. You can try it! Supplement: Pay attention to building 3.5 projects, if it is 2.0. The configuration file will be referenced much less if you are building a 2.0 project. Build a 3.5. Just overwrite the 3.5 configuration file to the 2.0 project! If the above code pops up "{d:test}" after success, it is because it returns a string, we can change it to return a json object. Modify the jquery code as follows
We set the data it returns to be a json object, and now we can use the returned json Object, according to the d:test that pops up, we can clearly see that the key is d and the value is test. Then we use the returned data msg object to directly click d to get the test. After modifying the code. Now it pops up It's just a test...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn