CodeCanyon

JavaScript variable to PHP variable?

15 posts
  • Has been a member for 2-3 years
  • Bought between 50 and 99 items
  • Germany
denysS says

Is it such easy or just not possible??? Do ia have to use AJAX ?(noob)

I have a Javascript variable:

var UserID = 1;

I want to use the UserID for an already loaded/created PHP -Array. HOW ?

4 months ago
260 posts
  • Has been a member for 3-4 years
  • Grew a moustache for the Envato Movember competition
  • Author had a Free File of the Month
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 10 and 49 items
  • United Kingdom
  • Referred between 1 and 9 users
ravenwill says

Hiya,

Yep ajax is the way, your converting from client side to server side code.

You could easily make a javascript value from php by echoing out script but not the other way around

4 months ago
15 posts
  • Has been a member for 2-3 years
  • Bought between 50 and 99 items
  • Germany
denysS says

Okay, so i was right… i really have to learn AJAX ..thanks!

4 months ago
278 posts
  • Has been a member for 1-2 years
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 10 and 49 items
  • Netherlands
  • Referred between 1 and 9 users
RikdeVos says

Just use jQuery. It makes life a lot easier :)

4 months ago
200 posts
  • Has been a member for 2-3 years
  • Exclusive Author
  • Sold between 1 000 and 5 000 dollars
  • Bought between 1 and 9 items
  • Canada
  • Referred between 10 and 49 users
iLochie says

Just use jQuery. It makes life a lot easier :)
$.post('file.php',{'userid':1},function(data){
     console.log(data);
});
;)
4 months ago
by
by
by
by
by