Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

jQuery AJAX problem

Featured Replies

Hi,

 

I am trying to submit XML values via a form using jQuery. I then need to process the returned XML. I am testing using the following jQuery:

 

1. $(document).ready(function(){

2. jQuery('input#process_card').click(function(){

3. $.post("https://secure2.epdq.co.uk:11500", $("#testform"), function(data){

4. jQuery('.confirm').hide();

5. });

6. });

7. });

 

 

and the following HTML form:

 

 

1. <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" id="testform">

2. <input type="hidden" name="CLRCMRC_XML" value='<EngineDocList>

3. <DocVersion>1.0</DocVersion>

4. <EngineDoc>

5. <ContentType>OrderFormDoc</ContentType>

6. <User>

7. <Name>URAdmin</Name>

8. <Password>TT2Access</Password>

9. <ClientId DataType="S32">49868</ClientId>

10. </User>

11. <Instructions>

12. <Pipeline>Payment</Pipeline>

13. </Instructions>

14. <OrderFormDoc>

15. <Mode>P</Mode>

16. <Id>01</Id>

17. <Consumer>

18. <Email>john@urbanriver.com</Email>

19. <BillTo>

20. <Location>

21. <Address>

22. <FirstName>John</FirstName>

23. <LastName>Barker</LastName>

24. <Street1>113 Borough Road</Street1>

25. <Street2></Street2>

26. <Street3></Street3>

27. <City>Jarrow</City>

28. <StateProv>Tyne and Wear</StateProv>

29. <PostalCode>NE32</PostalCode>

30. <Country>826</Country>

31. </Address>

32. </Location>

33. </BillTo>

34. <ShipTo>

35. <Location>

36. <Address>

37. <FirstName>Jane</FirstName>

38. <LastName>Smith</LastName>

39. <Street1>22 High Street</Street1>

40. <Street2></Street2>

41. <Street3></Street3>

42. <City>Northampton</City>

43. <StateProv>Northants</StateProv>

44. <PostalCode>NN1 1NN</PostalCode>

45. <Country>826</Country>

46. </Address>

47. </Location>

48. </ShipTo>

49. <PaymentMech>

50. <CreditCard>

51. <Type DataType="S32">1</Type>

52. <Number>4921819895586270</Number>

53. <Expires DataType="ExpirationDate" Locale="826">07/12</Expires>

54. <IssueNum></IssueNum>

55. <StartDate DataType="StartDate">04/09</StartDate>

56. <Cvv2Indicator>1</Cvv2Indicator>

57. <Cvv2Val>703</Cvv2Val>

58. </CreditCard>

59. </PaymentMech>

60. </Consumer>

61. <Transaction>

62. <Type>Auth</Type>

63. <CurrentTotals>

64. <Totals>

65. <Total DataType="Money" Currency="826">1</Total>

66. </Totals>

67. </CurrentTotals>

68. <CardholderPresentCode DataType="S32">7</CardholderPresentCode>

69. <PayerSecurityLevel DataType="S32"></PayerSecurityLevel>

70. <PayerAuthenticationCode></PayerAuthenticationCode>

71. <PayerTxnId></PayerTxnId>

72. </Transaction>

73. </OrderFormDoc>

74. </EngineDoc>

75. </EngineDocList>' />

76. <input type="button" value="go" name="process_card" id="process_card">

77. <input type="reset" value="reset">

78. </form>

 

I am tring to submit the form to the URL https://secure2.epdq.co.uk:11500. It is not working.

 

Any help is greatly appreciated.

 

Thanks

 

-John

Not sure if you can do this, as surely you gert the cross domain js error?????

 

Yeah, their are three popular approaches to cross domain ajax.

 

1) JSON (jQuery has something to do with this built in i think, but i've never used it)

2) Flash (Never used).

3) Use php as a gateway/proxy

 

Number three is the method i'd use. It's pretty simple.

 

  • Form sends an ajax request to a php script on your server (same domain).
  • The php script then sends the request to the target (different domain).
  • The php script then waits for the response
  • The php script then returns the response back to the original page.

The benefits of the php method is you can easily log, track and monitor data requests (success rates, bugs, failures etc.) You can also pre-process the data, reformat it etc. You get alot more flexibility and control to implement contingency procedures.

 

It's worth noting though, that subdomains are counted as a different domain. You CANNOT use ajax between different subdomains.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.