[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

What's wrong with my AJAX request?

Posted on 2014-09-01
10
Medium Priority
?
195 Views
Last Modified: 2016-02-26
I have written a SOAP service that has a number of different methods.  I have tested these with php clients and each method works fine.

Now I am trying to access the service using jQuery AJAX.

I think the problem relates to my URL rather than the parameters but I'm not entirely sure.

Any pointers?

<script>
function getGroups() {
			{
                  $('#div1').load("/server.php?getSubGroupsOfType",{"ParentGroupID":81,"TypeID":25});
			}
}
$(document).ready(function(){
  getGroups();
  });
;
</script>

Open in new window


I am specifically interested in whether calling a method of a service using

?getSubGroupsOfType

Open in new window


in the URL is valid or not
0
Comment
Question by:markremms
  • 7
  • 3
10 Comments
 

Author Comment

by:markremms
ID: 40296437
The php call I have used using a nuSOAP client is:
$result = $c->call('getSubGroupsOfType', array('ParentGroupID'=>$ParentGroupID, 'TypeID'=>$TypeID));

Open in new window

In my javascript I have deliberately used values that I know will have a result for ParentGroupID and TypeID.
0
 

Author Comment

by:markremms
ID: 40296438
I get a POST 500 internal server error which makes me think that the request is badly formed.
0
 
LVL 43

Accepted Solution

by:
Rob earned 2000 total points
ID: 40296578
?getSubGroupsOfType

What gave you the idea to use this?  Typically the SOAP call would happen in PHP, not at the client so you would pass the method as a parameter as well:

$('#div1').load("/server.php",{"method": "getSubGroupsOfType", "ParentGroupID":81,"TypeID":25});

Then parse the method and parameters in server.php and in turn make the SOAP call.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:markremms
ID: 40296675
Hmm - I thought that it was going to be possible to do the call direct to the server.  If not then I do have php clients that already work - just wasn't what I was expecting to do.

Thanks for the suggestion.

is a direct call really not a possibility?
0
 
LVL 43

Expert Comment

by:Rob
ID: 40296680
Is it on the same domain?
0
 

Author Comment

by:markremms
ID: 40296682
It is at the moment but in the end I want to allow external access.  I know that is another issue but I want to get it working locally in the first place.
0
 

Author Comment

by:markremms
ID: 40296684
BTW - I can confirm that using the php client does give me results.  So that is a solution even if it's not what I was expecting!
0
 
LVL 43

Expert Comment

by:Rob
ID: 40296692
:) sure, not the one you wanted.

Can you post your server.php code?  How does it process the parameters?  Is it a class with methods?
0
 

Author Comment

by:markremms
ID: 40296714
It's built using nuSOAP and yes it is a class with methods.

I have built a php client for each method and they work fine when called from a form.

I have now established that they are also fine if called from $('#div1').load too.

I'm about to give you the points for this and set up a related question if you're still around?
0
 

Author Closing Comment

by:markremms
ID: 40296715
Not the solution I expected but totally workable
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.NET AJAX callbacks to web service are becoming very popular and unavoidable these days. The feel that the user gets when only a part of the page is updated without even hindering the UI is the advantage that the callbacks offer. The wait for the…
This article discusses how to implement server side field validation and display customized error messages to the client.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

826 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question