I have a simple ajax call, for example:
$.ajax({ url: u, type: "POST", dataType: "json", data: data, success: function (d) { response($.map(d, function (o) { return { label: o.Text, value: o.Text, id: o.Id} })); } });
This is the tb autocomplete part that doesn't work on just one view. The reason it doesn't work is because instead of json it makes a jsonp request (sniffed, I saw that it calls the passed url with ?callback=jQueryxxxxxxxxx ), and the success function is never called because jquery packs it into an anonymous function whose name is passed into the callback argument, and the server returns standard json (I do not want to use jsonp, since this is a POST request and NOT a cross-domain domain request). I checked both the current URL and this u for the ajax url argument are at http://localhost:8080/myapp/areax/... , so I don't understand why jQuery makes a JSONP request here.
EDIT:
The view on which this does not work is requested by requesting the URL: http: // hostname: 8080 / AreaName / Report / ViewReport and u the ajax parameter is similar to / AreaName / MyAutoComplete / Search, so the full URL to which autocomplete is performed, similar to http: // hostname: 8080 / AreaName / MyAutoComplete / Search? callback = jQuery151013129048690121925_1327065146844
The server response is as follows:
[{"Id":2,"Text":"001"},{"Id":7,"Text":"002"}]
I know this is not jsonp, for this it must be
<script> jQuery151013129048690121925_1327065146844([{"Id":2,"Text":"001"},{"Id":7,"Text":"002"}]); </script>
But I want to make a regular json request, not jsonp.
UPDATE
The strangest thing (I'm starting to think that this is a bug in jQuery v1.5.1, which is used in the project) is that when I delete dataType: "json" , it makes a normal json request :)
So, instead of making a json request, now I will accept an explanation of why this works as expected (and one with dataType: βjsonβ does not):
$.ajax({ url: u, type: "POST", data: data, success: function (d) { response($.map(d, function (o) { return { label: o.Text, value: o.Text, id: o.Id} })); } });