English 中文(简体)
Jquery.cascade plugin change the format of the Ajax URL
原标题:

I m using the jQuery.Cascade plugin in my Asp.Net MVC application. I ve got it all working in a manner as follows:

jQuery("#CompareModelList").cascade("#CompareManufacturerList", {
                ajax: { url:  /Home/Models  },
                template: commonTemplate,
                match: function (selectedValue) { return this.ManufacturerId == selectedValue;},
            });

However, when this fires it calls the action in my controller via the following request:

http://localhost/Home/Models?val=50

What I would prefer is:

http://localhost/Home/Models/50

Now in the examples provided there is the following comment:

Passes selected value of parent select to url as val= , but accepts the full ajax options hash so you can append other data as well

So I m presuming what I wish to achieve is possible - but as a newcommer to jQuery and Ajax I m at a loss as to how to do this. Can anyone help?

最佳回答

The Cascade plugin is creating the default AJAX options (example: http://docs.jquery.com/Types#Options) which are:

    type: "GET",
    dataType: "json",
    success: function(json) { $this.trigger("updateList", [json]); },
    data: $.extend(_ajax.data,ajax.data,{ val: opt.getParentValue(parent) })

In other words, change the line:

ajax: { url: /Home/Models }

to

ajax: { url: /Home/Models/ + jQuery( #CompareManufacturerList ).val() }

instead.

问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

How can i update div continuously

I have asp.net application where i have a div which showing the value from other site. The value of that site is changing continuously. I want that my div will automatically update in some interval ...

热门标签