开发者

jquery ajax type GET question

I hava a simple question. I have a server running which take actions according to parameters in the url.

Example: if I type in browser: http://localhost:8081/Edit?action=renameModule&newName=Module2

This 开发者_开发百科works correctly.

I would like to know the equivalent jquery ajax method to perform the same thing

I have tried

$.ajax({ url: 'http://localhost:8081/Edit', type: 'GET', data:'action=renameModule&newName=Module2 });

It is not working.

I would be very grateful for any help.

Thanks


This could be due to some cross domain restrictions. You can perform AJAX calls only to resources which are hosted on the same domain/port as the HTML page performing the request. If this is not the case you could also try this call:

$.ajax({ 
    url: 'http://localhost:8081/Edit', 
    type: 'GET', 
    data: { 
        action : 'renameModule', 
        newName: 'Module2' 
    }
});

or using the get function:

$.get('http://localhost:8081/Edit', { 
    action : 'renameModule', 
    newName: 'Module2' 
});


why can't you use

$.ajax({ 
    url: 'http://localhost:8081/Edit?action=renameModule&newName=Module2', 
    type: 'GET' 
});

edit : in the example you supplied, you're missing a ' from the end of the data param, maybe that is the problem?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜