开发者

Using Visual Studio 2010 for AJAX?

开发者 https://www.devze.com 2022-12-20 09:09 出处:网络
I\'m doing a short AJAX project, and I\'d like to use Visual Studio 2010. It\'s just xHTML and JavaScript, with calls to a serverside .php file. What is the best way to set 开发者_JAVA技巧up a project

I'm doing a short AJAX project, and I'd like to use Visual Studio 2010. It's just xHTML and JavaScript, with calls to a serverside .php file. What is the best way to set 开发者_JAVA技巧up a project/solution for this in VS? I see a lot of project templates having to do with ASP.NET.

Also, when I choose to Add New Item, I get "Ajax Client Control", "Ajax Client Behavior", etc as a file template. What's that? Is it worth using when I expect only to spend ~5 hours on this project? Or should I just make a blank JavaScript file, like I'm used to?

(Right now, I choose to make a project of the template Empty C# Web App. This seems dubious.)


Don't mess around with the Items marked as AJAX. Those are controls for the ASP.NET AJAX Toolkit and won't help you here.

Your best bet is to stick to jQuery and make your AJAX calls to the *.php scripts that way.

In this case, .NET isn't even really needed...it's all HTML and Javascript (using jQuery unless you're feeling adventurous).

...if you really want to shoehorn some .NET in to the picture and overcomplicate things, you could add a Web Reference to the *.php services and then use the .NET AJAX Toolkit to force the server to make the call to the PHP service. I don't condone doing it this way, it just makes things more complicated.


Do you really need a VS-project at all for this? Just create the files you need and drag them into VS for editing, syntax highlighting and other goodies, and never mind the project/solution :)

Otherwise an empty project of any kind should be fine - you're not going to compile/publish it through VS right?


I'm going to assume that you have a localhost webserver which handles your php file which and is already configured to work with php. So the easiest way to do this is to open Visual Studio, click Shift + Alt + O (this opens a website). Navigate to the folder where your php file is located.

This will load the folder into the solution explorer. You can now right click on the project and add new item (HTML page and JavaScript in your case).

You should now be set to do some Ajax magic. To test your page, just open your browser, goto your localhost/phpAjaxFolder/ajaxPage.html and see what happens.

(I've made a lot of assumptions here, but this should be the general way of working with your project.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号