Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi guys,
This is my first post :)
The issue is I have is I'm able to post using a jQuery event to a .cshtml if I'm not using umbraco.
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js"></script> <p id="load">load</p> <script type="text/javascript"> $("#load").click(function () { $.post("/Scripts/FileUpload3", { name: "John", time: "2pm" }, function (data) { alert("Data Loaded: " + data); }); }); </script>
The .cshtml file is submitting some info to a database and the project workes very well.
Any ideas why this will not work in a umbraco enviroment?
Thank you
Cornel
Hi. What is '/Scripts/FileUpload3' ? From the code it looks that it's supposed to be sort of a web service. Is it really accesible by this url?
Hi Rodion,
Thank you for your reply.
/Scripts/FileUpload3.cshtml
Strangly but is working without the extension.
I've tryed it with and without the extension in umbraco but still nothing.
Hi Cornel--
If I recall correctly, you need to explicitly expose the methods in the assembly to be able to use AJAX calls in the /config/restExtensions.config file. More information on it can be found at http://our.umbraco.org/wiki/reference/umbraco-base/simple-base-samples/the-restextensionsconfig-file
Hope this is what you're looking for--Andrew
Hi Cornel
Have a look at Sebastiaan blog post on Razor vs "/base" to output JSON in Umbraco, http://cultiv.nl/blog/2011/7/25/razor-vs-base-to-output-json-in-umbraco/
Basically you have the two options write a class using umbraco base or follow the example in the blod post to use Razor.
If you have an Umbraco Tv subscription I'd also reccomend having a look at these two videos on base;
http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/base-and-ajax-development/introduction-to-base.aspx
http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/base-and-ajax-development/creating-an-ajax-form.aspx
@andrew - you can now attribute you base classes and methods to expose them instead of editing the restExtensions.config.
using umbraco.presentation.umbracobase;
[RestExtension("myAlias")]class myBaseClass.....
[RestExtensionMethod(returnXml= false)]public static string Save(string reportId)....
Cheers
Evan
Hi, Cornel. I also tried to use a .cshtml page inside Umbraco and found that there're also other things that should be taken into consideration.
I googled the link below and think that it can be very usefull to read:
http://joeriks.wordpress.com/2011/03/03/an-ordinary-webmatrix-app-in-an-umbraco-subfolder/
@Rodion,
The thing that I want to do is not just loading a cshtml. I want ot post on a jQuery event some data to a cshtml.
The jQuery event is very important because I want to do it without a refresh.
@Evan,
I think that the video create an ajax form should solve my problem.
Because one the topics is submitting your form using a jQuery event.
I'll watch it later today and let you know.
@Andrew
Maybe this sounds crazy, but I'm pretty new to this stuff.
How do I "explicitly expose the methods in the assembly to be able to use AJAX calls in the /config/restExtensions.config file" :)
Yeh, I understand that. However, calling it with jQuery technically doesn't differ from usual http post/get methods, so you can use for instance the console/network panels of FireBug to trace it. Can you do it and tell if there're any errors?
Have you added the Scripts folder in umbracoReservedPaths in web.config ? If not, Umbraco will hijack the web service I think
hth
Jay
@Jay
It is now but still nothing :)
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/scripts/" />
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.
Continue discussion
On Click jQuery post to razor file
Hi guys,
This is my first post :)
The issue is I have is I'm able to post using a jQuery event to a .cshtml if I'm not using umbraco.
The .cshtml file is submitting some info to a database and the project workes very well.
Any ideas why this will not work in a umbraco enviroment?
Thank you
Cornel
Hi. What is '/Scripts/FileUpload3' ? From the code it looks that it's supposed to be sort of a web service. Is it really accesible by this url?
Hi Rodion,
Thank you for your reply.
/Scripts/FileUpload3.cshtml
Strangly but is working without the extension.
I've tryed it with and without the extension in umbraco but still nothing.
Thank you
Cornel
Hi Cornel--
If I recall correctly, you need to explicitly expose the methods in the assembly to be able to use AJAX calls in the /config/restExtensions.config file. More information on it can be found at http://our.umbraco.org/wiki/reference/umbraco-base/simple-base-samples/the-restextensionsconfig-file
Hope this is what you're looking for-
-Andrew
Hi Cornel
Have a look at Sebastiaan blog post on Razor vs "/base" to output JSON in Umbraco, http://cultiv.nl/blog/2011/7/25/razor-vs-base-to-output-json-in-umbraco/
Basically you have the two options write a class using umbraco base or follow the example in the blod post to use Razor.
If you have an Umbraco Tv subscription I'd also reccomend having a look at these two videos on base;
http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/base-and-ajax-development/introduction-to-base.aspx
http://umbraco.com/help-and-support/video-tutorials/developing-with-umbraco/base-and-ajax-development/creating-an-ajax-form.aspx
@andrew - you can now attribute you base classes and methods to expose them instead of editing the restExtensions.config.
using umbraco.presentation.umbracobase;
[RestExtension("myAlias")]
class myBaseClass.....
[RestExtensionMethod(returnXml= false)]
public static string Save(string reportId)....
Cheers
Evan
Hi, Cornel. I also tried to use a .cshtml page inside Umbraco and found that there're also other things that should be taken into consideration.
I googled the link below and think that it can be very usefull to read:
http://joeriks.wordpress.com/2011/03/03/an-ordinary-webmatrix-app-in-an-umbraco-subfolder/
@Rodion,
The thing that I want to do is not just loading a cshtml. I want ot post on a jQuery event some data to a cshtml.
The jQuery event is very important because I want to do it without a refresh.
Thank you
Cornel
@Evan,
I think that the video create an ajax form should solve my problem.
Because one the topics is submitting your form using a jQuery event.
I'll watch it later today and let you know.
Thank you
Cornel
@Andrew
Maybe this sounds crazy, but I'm pretty new to this stuff.
How do I "explicitly expose the methods in the assembly to be able to use AJAX calls in the /config/restExtensions.config file" :)
Thank you
Cornel
Yeh, I understand that. However, calling it with jQuery technically doesn't differ from usual http post/get methods, so you can use for instance the console/network panels of FireBug to trace it. Can you do it and tell if there're any errors?
Have you added the Scripts folder in umbracoReservedPaths in web.config ? If not, Umbraco will hijack the web service I think
hth
Jay
@Jay
It is now but still nothing :)
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.