Quantcast
Channel: blog.mehl-web.de - webservice
Viewing all articles
Browse latest Browse all 18

How to get jquery to perform a synchronous ajax request

$
0
0

I had the problem that i dont want to do a asynchronous request with jquery ajax. So i did search for a real solution for me.

I also had the difficulty that it is a crossdomain call. So i have to use jsonp as well.

The solution i have found is as follow:

  _getObj = function () {
                var data = JSON.parse($.ajax({
                    type: "GET",
                    contentType: "application/json; charset=utf-8",
                    url: url,
                    async: false,
                    dataType: "json"
                }).responseText);

                var m = new foo();
                m.gesamteuros = data.d.foo;
                return m;
            },

Important here is the assignment, the data variable gets the ajax response.

Next is the return obj  part in the function.

As a result it finally works for me.


Viewing all articles
Browse latest Browse all 18

Latest Images

Trending Articles





Latest Images