tags:

views:

25

answers:

3

Hi all!

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

A: 

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?

oedo
It was the cross-domain issue. Thank you for your help!!
Andrew Jackson
+1  A: 

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' 
});
Darin Dimitrov
It was the cross-domain issue. Thank you for your help!!
Andrew Jackson
A: 

It was the cross-domain issue. Thank you for your help!!

Andrew Jackson
Please don't post another answer. Use the comments section.
Darin Dimitrov