如何在ajax函数中提供URL [英] how to give the url in ajax function

查看:127
本文介绍了如何在ajax函数中提供URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我必须使用ajax在控制器中调用操作方法.我的操作方法在Controller(文件夹)-> Contacts(子文件夹)-> ContactProfile(控制器名称)-> Index(操作方法)中. />
在我的Ajax函数中,我在Url中提到了
网址:''/ContactProfile/Index"和网址:''@ Url.Action("Index","Contactprofile")''

但是当我在Index方法中放置断点时,它没有调用Index方法.

您能告诉我如何传递url


I have to call the action method in the controller using the ajax.My action method is in Controller(folder)->Contacts(sub folder)->ContactProfile(controller name)->Index(action method).

In my ajax function I mentioned in the Url like
Url:''/ContactProfile/Index'' and Url:''@Url.Action("Index","Contactprofile")''

but when i put break point in the Index method it is not calling the Index method.

can u tell me how to pass the url

推荐答案

我不确定我是否遵循此处,Controller是您URL的一部分吗?我也没有收到问题-您的AJAX方法是否获得正确的URL?假设这是JSON,我看不出为什么不这样做.但是您说断点在index方法中.仅仅是因为您将URL传递给AJAX方法,并不意味着该页面被调用,实际上,因为您使用了AJAX,浏览器并未发出页面请求,因此无法调用该页面请求,除非您对AJAX调用是从浏览器重定向整个页面.

您可能没有很好地解释它,或者您不了解AJAX的用途和作用.
I''m not sure I follow here, Controller is part of your URL ? I also don''t get the question - is your AJAX method getting the correct URL or not ? I don''t see why it wouldn''t, assuming this is JSON. But you say your breakpoint is in the index method. Just because you passed a URL to an AJAX method, does not mean that page is called, in fact, because you used AJAX, the browser is not making a page request, so it can''t be called, unless your response to the AJAX call is to redirect from the browser for the whole page.

You''ve either not explained it very well, or you don''t understand what AJAX is and does.


这篇关于如何在ajax函数中提供URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆