kruegerm
kruegerm

Reputation: 1

Need to call perl script from javascript

I have written a perl script I can access from a URL: https://hostname/myweb/myScript.pl?id=1234&stg=13 I get the proper results using the URL

In javascript/jscript, I have tried loading the script ($('#element').load()) - I've tried full ajax calls within a function:

  $.ajax({
    url: '/myweb/myScript.pl',
    type: 'post',
    data: {
      'id' : '1234',
      'stg' : '13'
    }
  });

I am not having any success. If anyone can point me in the right direction, it would be greatly appreciated!

M

Upvotes: 0

Views: 195

Answers (1)

Jens
Jens

Reputation: 69515

Looks like your perl script expect a get request not a post request try:

 $.ajax({
    url: '/myweb/myScript.pl?id=1234&stg=13',
    type: 'get'
  });

if you would like use data you can do it this way:

 $.ajax({
    url: '/myweb/myScript.pl',
    type: 'get',
    data: {
      'id' : '1234',
      'stg' : '13'
   }

  });

this should work too

Upvotes: 1

Related Questions